net.i2p.util
Class Translate

java.lang.Object
  extended by net.i2p.util.Translate
Direct Known Subclasses:
Messages

public abstract class Translate
extends java.lang.Object

Translate strings efficiently. We don't include an English or default ResourceBundle, we simply check for "en" and return the original string. Support real-time language changing with the routerconsole.lang property.

Since:
0.7.9
Author:
zzz, from a base generated by eclipse.

Field Summary
static java.lang.String PROP_LANG
           
 
Constructor Summary
Translate()
           
 
Method Summary
static void clearCache()
          Clear the cache.
static java.lang.String getLanguage(I2PAppContext ctx)
           
static java.lang.String getString(int n, java.lang.String s, java.lang.String p, I2PAppContext ctx, java.lang.String bun)
          Use GNU ngettext For .po file format see http://www.gnu.org/software/gettext/manual/gettext.html.gz#Translating-plural-forms
static java.lang.String getString(java.lang.String key, I2PAppContext ctx, java.lang.String bun)
          lang in routerconsole.lang property, else current locale
static java.lang.String getString(java.lang.String s, java.lang.Object o, I2PAppContext ctx, java.lang.String bun)
          translate a string with a parameter This is a lot more expensive than getString(s, ctx), so use sparingly.
static java.lang.String getString(java.lang.String s, java.lang.Object o, java.lang.Object o2, I2PAppContext ctx, java.lang.String bun)
          for {0} and {1}
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_LANG

public static final java.lang.String PROP_LANG
See Also:
Constant Field Values
Constructor Detail

Translate

public Translate()
Method Detail

getString

public static java.lang.String getString(java.lang.String key,
                                         I2PAppContext ctx,
                                         java.lang.String bun)
lang in routerconsole.lang property, else current locale


getString

public static java.lang.String getString(java.lang.String s,
                                         java.lang.Object o,
                                         I2PAppContext ctx,
                                         java.lang.String bun)
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 tranlslate parameter also, use _("foo {0} bar", _("baz")) Do not double the single quotes in the parameter. Use autoboxing to call with ints, longs, floats, etc.

getString

public static java.lang.String getString(java.lang.String s,
                                         java.lang.Object o,
                                         java.lang.Object o2,
                                         I2PAppContext ctx,
                                         java.lang.String bun)
for {0} and {1}


getString

public static java.lang.String getString(int n,
                                         java.lang.String s,
                                         java.lang.String p,
                                         I2PAppContext ctx,
                                         java.lang.String bun)
Use GNU ngettext For .po file format see http://www.gnu.org/software/gettext/manual/gettext.html.gz#Translating-plural-forms

Parameters:
n - how many
s - singluar string, optionally with {0} e.g. "one tunnel"
p - plural string optionally with {0} e.g. "{0} tunnels"
Since:
0.7.14

getLanguage

public static java.lang.String getLanguage(I2PAppContext ctx)
Returns:
lang in routerconsole.lang property, else current locale

clearCache

public static void clearCache()
Clear the cache. Call this after adding new bundles to the classpath.

Since:
0.7.12