java.lang.Object
net.i2p.util.Translate
net.i2p.router.web.Messages
Translate strings for this package.
Field Summary
Fields inherited from class Translate
PROP_COUNTRY, PROP_LANGConstructor Summary
Method Summary
All MethodsModifier and TypeMethodDescriptionstatic StringgetDisplayLanguage(String langCode, String dflt, I2PAppContext ctx) Return the "display language", e.g.static StringgetString(int n, String s, String p, I2PAppContext ctx) Translate a string picking between the singular and the plural form, as the GNU gettext plural-forms rules require.static StringgetString(String s, Object o, Object o2, I2PAppContext ctx) Translate a string carrying two parameters.static StringgetString(String s, Object o, I2PAppContext ctx) Translate a string with a parameter This is a lot more expensive than getString(s, ctx), so use sparingly.static StringgetString(String key, I2PAppContext ctx) Look up a string in this package's bundle.Methods inherited from class Translate
clearCache, getCountry, getDisplayLanguage, getLanguage, getString, getString, getString, getString, getString, isRTL, isRTL, setLanguageModifier and TypeMethodDescriptionstatic voidClear the cache.static StringgetCountry(I2PAppContext ctx) Two-letter upper case or "".static StringgetDisplayLanguage(String langCode, String dflt, I2PAppContext ctx, String bun) Return the "display language", e.g.static StringgetLanguage(I2PAppContext ctx) Two- or three-letter lower case.static StringgetString(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-formsstatic StringFor {0} and {1}.static StringgetString(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 StringgetString(String key, I2PAppContext ctx, String bun) Look up a single translation key in a resource bundle.static StringgetString(String s, I2PAppContext ctx, String bun, Object... oArray) Varargs form, accepting any number of values substituted for the {0}, {1}, ...static booleanIs this a right-to-left language?static booleanisRTL(I2PAppContext ctx) Are we configured for a right-to-left language?static voidsetLanguage(String lang, String country) Only for use by standalone apps in App Context.
Field Details
BUNDLE_NAME
The bundle holding the console's translated strings.- See Also:
COUNTRY_BUNDLE_NAME
Resource bundle for country names, looked up separately from this package's own strings so the country list can be translated on its own.- See Also:
Constructor Details
Messages
public Messages()Not used: every method here is static, and this class exists only to bind the package's own bundle name toTranslate.
Method Details
getString
Look up a string in this package's bundle.- Parameters:
key- the translation key, holding the English text when untranslatedctx- supplies therouterconsole.langproperty, else current locale- Returns:
- the translated string, or the key itself when no translation exists
getString
Translate a string with a parameter This is a lot more expensive than getString(s, ctx), so use sparingly.- Parameters:
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.ctx- supplies therouterconsole.langproperty, else current locale- Returns:
- the translated string, with {0} replaced by the parameter
getString
Translate a string carrying two parameters.- Parameters:
s- string to be translated containing {0} and {1}o- first parameter, not translatedo2- second parameter, not translatedctx- supplies therouterconsole.langproperty, else current locale- Returns:
- the translated string, with {0} and {1} replaced
getString
Translate a string picking between the singular and the plural form, as the GNU gettext plural-forms rules require.- Parameters:
n- the count, used to choose between s and ps- singular string, may contain {0} for the countp- plural string, may contain {0} for the countctx- supplies therouterconsole.langproperty, else current locale- Returns:
- s or p, per the plural rules for n
getDisplayLanguage
Return the "display language", e.g. "English" for the language specified by langCode, using the current language. Uses translation if available, then JVMLocale.getDisplayLanguage()if available, else default param.- Parameters:
langCode- two-letter lower-case language code whose name is wanted, e.g. "en"dflt- returned untranslated when the current language is "en", when the bundle has no entry for it, or when the JVM has no display name for langCode in the current languagectx- supplies the language to display the name in- Returns:
- the display language