定义统一Locale修复获取国际化信息错误问题(I8Z7DA)
This commit is contained in:
parent
0ce40fc039
commit
8f17a42b97
|
|
@ -1,5 +1,7 @@
|
||||||
package com.ruoyi.common.constant;
|
package com.ruoyi.common.constant;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用常量信息
|
* 通用常量信息
|
||||||
*
|
*
|
||||||
|
|
@ -57,6 +59,11 @@ public class Constants
|
||||||
*/
|
*/
|
||||||
public static final String LOGIN_FAIL = "Error";
|
public static final String LOGIN_FAIL = "Error";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统统一Locale
|
||||||
|
*/
|
||||||
|
public static final Locale SYS_LOCALE = Locale.SIMPLIFIED_CHINESE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统用户授权缓存
|
* 系统用户授权缓存
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.ruoyi.common.utils;
|
package com.ruoyi.common.utils;
|
||||||
|
|
||||||
|
import com.ruoyi.common.constant.Constants;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21,6 +21,6 @@ public class MessageUtils
|
||||||
public static String message(String code, Object... args)
|
public static String message(String code, Object... args)
|
||||||
{
|
{
|
||||||
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
|
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
|
||||||
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
|
return messageSource.getMessage(code, args, Constants.SYS_LOCALE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package com.ruoyi.framework.config;
|
package com.ruoyi.framework.config;
|
||||||
|
|
||||||
import java.util.Locale;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.LocaleResolver;
|
import org.springframework.web.servlet.LocaleResolver;
|
||||||
|
|
@ -22,7 +22,7 @@ public class I18nConfig implements WebMvcConfigurer
|
||||||
{
|
{
|
||||||
SessionLocaleResolver slr = new SessionLocaleResolver();
|
SessionLocaleResolver slr = new SessionLocaleResolver();
|
||||||
// 默认语言
|
// 默认语言
|
||||||
slr.setDefaultLocale(Locale.SIMPLIFIED_CHINESE);
|
slr.setDefaultLocale(Constants.SYS_LOCALE);
|
||||||
return slr;
|
return slr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue