提交 8f5b0b93 编写于 作者: chenxiang@lab.ibiz5.com's avatar chenxiang@lab.ibiz5.com

2022.11.10.001 i18n国际化支持

上级 5b820811
...@@ -5,6 +5,8 @@ spring: ...@@ -5,6 +5,8 @@ spring:
name: {{lowerCase system.deploySysId}} name: {{lowerCase system.deploySysId}}
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
messages:
basename: i18n/messages
server: server:
servlet: servlet:
contextPath: /{{lowerCase system.deploySysId}} contextPath: /{{lowerCase system.deploySysId}}
package {{packageName}}.util.message;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;
/**
* 国际化工具类
*/
@Component
public class MessageUtils {
private static MessageSource messageSource;
public MessageUtils(MessageSource messageSource) {
MessageUtils.messageSource = messageSource;
}
/**
* 获取单个国际化翻译值
*/
public static String get(String msgKey) {
try {
return messageSource.getMessage(msgKey, null, LocaleContextHolder.getLocale());
} catch (Exception e) {
return msgKey;
}
}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册