whycrzg
2021-02-19 656bd1b190ed296a7bf63623dc8e9fe2bc9d3098
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.fgkj.controller;
 
import com.fgkj.util.*;
 
import com.fgkj.dto.ServiceModel;
import com.fgkj.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.Locale;
 
import javax.annotation.Resource;
 
@RequestMapping("i18n")
@RestController
@Api(tags = "i18n接口")
public class I18nController{
 
    // private String lanuage;
    // private String key;
    // private String value;
 
    public ServiceModel findValue(){
        ServiceModel model=new ServiceModel();
        //System.out.println(key+"&&&&&&&&&&&&");
        // value=this.getText(key); //这是Struts的ActionSupport的方法
        //value=ActionUtil.tojson(value);
        //System.out.println(value+"$$$$$$$");
        return model;
    }
    
    //切换中英文环境
    @PutMapping("locale")
    @ApiOperation(notes = "",value="切换中英文环境")
    public boolean SetLocale(@RequestParam String lanuage){
        boolean res=false;
        Locale local = Locale.getDefault();
        if(lanuage!=null){
            if("US".equalsIgnoreCase(lanuage)){
                local = Locale.US;
                
            }else if("CH".equalsIgnoreCase(lanuage)){
                local = Locale.CHINA;
            }
            //System.out.println(local.getCountry());
        }
        // ActionContext.getContext().setLocale(local);
 
        ActionUtil.getSession().setAttribute("WW_TRANS_I18N_LOCALE", local);
        res=true;
        return res;
    }
 
}