public abstract class Translate extends Object
| Modifier and Type | Field and Description |
|---|---|
static String | PROP_COUNTRY |
static String | PROP_LANGprop lang |
| Constructor and Description |
|---|
Translate() |
| Modifier and Type | Method and Description |
|---|---|
static void | clearCache()Clear the cache. |
static String | getCountry(I2PAppContext ctx)Two-letter upper case or "" |
static String | getDisplayLanguage(String langCode,
String dflt,
I2PAppContext ctx,
String bun)Return the "display language", e.g. |
static String | getLanguage(I2PAppContext ctx)Two- or three-letter lower case |
static String | getString(int n,
String s,
String p,
I2PAppContext ctx,
String bun)Use GNU ngettext
For .po file format see http://www.gnu.org/software/gettext/manual/gettext.html.gz#Translating-plural-forms |
static String | getString(String key,
I2PAppContext ctx,
String bun)lang in routerconsole.lang property, else current locale |
static String | getString(String s,
I2PAppContext ctx,
String bun,
Object... oArray)Varargs |
static String | getString(String s,
Object o,
I2PAppContext ctx,
String bun)Translate a string with a parameter
This is a lot more expensive than getString(s, ctx), so use sparingly. |
static String | getString(String s,
Object o,
Object o2,
I2PAppContext ctx,
String bun)for {0} and {1} |
static boolean | isRTL(I2PAppContext ctx)Are we configured for a right-to-left language? |
static boolean | isRTL(String lang)Is this a right-to-left language? |
static void | setLanguage(String lang,
String country)Only for use by standalone apps in App Context. |
public static final String PROP_COUNTRY
public static final String PROP_LANG
public static void clearCache()
public static String getCountry(I2PAppContext ctx)
public static String getDisplayLanguage(String langCode, String dflt, I2PAppContext ctx, String bun)
langCode - two- or three-letter lower-casedflt - e.g. "English"public static String getLanguage(I2PAppContext ctx)
ctx - the ctxpublic static String getString(int n, String s, String p, I2PAppContext ctx, String bun)
n - how manys - singluar string, optionally with {0} e.g. "one tunnel"p - plural string optionally with {0} e.g. "{0} tunnels"public static String getString(String key, I2PAppContext ctx, String bun)
public static String getString(String s, I2PAppContext ctx, String bun, Object... oArray)
oArray - parameterspublic static String getString(String s, Object o, I2PAppContext ctx, String bun)
s - string to be translated containing {0}
The {0} will be replaced by the parameter.
Single quotes must be doubled, i.e. ' -> '' in the string.o - parameter, not translated.
To translate parameter also, use _t("foo {0} bar", _t("baz"))
Do not double the single quotes in the parameter.
Use autoboxing to call with ints, longs, floats, etc.
4 * @param ctx the ctx
4 * @param bun the bun
4 * @return the resultpublic static String getString(String s, Object o, Object o2, I2PAppContext ctx, String bun)
public static boolean isRTL(I2PAppContext ctx)
public static boolean isRTL(String lang)
lang - Two- or three-letter lower casepublic static void setLanguage(String lang, String country)
lang - Two- or three-letter lower case, or null for defaultcountry - Two-letter upper case, or null for default, or "" for none