public class I18nUtils extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
I18nUtils.I18nMessageSource |
| 构造器和说明 |
|---|
I18nUtils(I18nUtils.I18nMessageSource messageSource) |
I18nUtils(I18nUtils.I18nMessageSource messageSource,
Function<String,String> variablesSource) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addVariables(String varName,
String varValue)
添加可替换变量
|
String |
getDefaultI18nKey() |
static Locale |
getLocale(String i18nKey)
根据 i8n Key 获取 Locale,i18nKey 格式为:"语言_国家"; 可以大小写不敏感
|
static Locale |
getLocale(String language,
String country)
根据 语言和国家代码获取 Locale,可以大小写不敏感
|
String |
getMessage(String code)
获取 i18n 文本
|
String |
getMessage(String code,
Object[] args)
获取 i18n 文本
|
String |
getMessage(String code,
Object[] args,
Locale locale)
获取 i18n 文本
|
String |
getMessage(String code,
Object[] args,
String i18nLocal)
获取 i18n 文本
|
static I18nUtils |
initI18n(ClassLoader resourceLoader,
String... i18nResources) |
static I18nUtils |
initI18n(String... i18nResources) |
void |
loadResources(Class<?>... i18nResources) |
protected void |
loadResources(ClassLoader resourceLoader,
String... i18nResources) |
protected void |
loadResources(String... i18nResources) |
void |
putVariables(Map<String,String> variables) |
protected String |
resolveArg(String argName) |
void |
setDefaultI18nKey(Locale defaultLocale) |
void |
setDefaultI18nKey(String defaultI18nKey) |
static String |
toI18nKey(Locale locale)
根据 Locale 生成 i18nKey
|
static String |
toI18nKey(String language,
String country)
根据 语言和国家代码 生成 i18nKey
|
public static final I18nUtils DEFAULT
public I18nUtils(I18nUtils.I18nMessageSource messageSource)
public I18nUtils(I18nUtils.I18nMessageSource messageSource, Function<String,String> variablesSource)
public static I18nUtils initI18n(String... i18nResources) throws IOException
IOExceptionpublic static I18nUtils initI18n(ClassLoader resourceLoader, String... i18nResources) throws IOException
IOExceptionpublic static Locale getLocale(String i18nKey)
public static Locale getLocale(String language, String country)
public String getDefaultI18nKey()
public void setDefaultI18nKey(String defaultI18nKey)
public void setDefaultI18nKey(Locale defaultLocale)
protected void loadResources(String... i18nResources) throws IOException
IOExceptionprotected void loadResources(ClassLoader resourceLoader, String... i18nResources) throws IOException
IOExceptionpublic void loadResources(Class<?>... i18nResources) throws IOException
IOExceptionCopyright © 2022–2023. All rights reserved.