public class I18n extends Object
Example:
1: Create resource file "demo_zh_CN.properties" content with: msg=你好 JFinal! 你好{0}!
Create resource file "demo_en_US.properties" content with: msg=Hello JFinal! Hello {0}!
2: Res res = I18n.use("demo", "zh_CN");
res.get("msg"); // return value: 你好 JFinal! 你好{0}!
res.format("msg", "詹波"); // return value: 你好 JFinal! 你好詹波!
res = I18n.use("demo", "en_US");
res.get("msg"); // return value: Hello JFinal! Hello{0}!
res.format("msg", "james"); // return value: Hello JFinal! Hello James!
Modifier and Type | Method and Description |
---|---|
static void |
setDefaultBaseName(String defaultBaseName) |
static void |
setDefaultLocale(String defaultLocale) |
static String |
toLocale(Locale locale) |
static Locale |
toLocale(String locale) |
static Res |
use() |
static Res |
use(String locale) |
static Res |
use(String baseName,
Locale locale) |
static Res |
use(String baseName,
String locale)
Using the base name and locale to get the Res object, which is used to get i18n message value from the resource file.
|
public static void setDefaultBaseName(String defaultBaseName)
public static void setDefaultLocale(String defaultLocale)
public static Res use(String baseName, String locale)
baseName
- the base name to load Resource bundlelocale
- the locale string like this: "zh_CN" "en_US"public static Res use()
Copyright © 2018. All rights reserved.