前言
区别:i18n-翻译语言不同,国际更注重隐私协议,国际更注重匿名,国际的每个国家时区不同
一、i18n是什么?
软件中的国际化是通过配置文件来实现的,假设某个软件要支撑两种语言,那么就需要两个版本的配置文件。
二、使用步骤
1定义properties
bootname_zh_CN.properties
bootname_en_US.properties
2.spring使用MessageSource接口实现国际化
public String getMessage(String code) {
String result = "";
try {
Locale locale = this.getLocale();
result = messageSource.getMessage(code, null, locale);
} catch (NoSuchMessageException e) {
log.warn("获取配置异常,不能找到" + code + "对应的语言配置。");
}
if(StringUtils.isBlank(result)){
result = code;
}
return result;
}