java.lang.Object
net.i2p.util.Translate
net.i2p.router.web.Messages

public class Messagesextends Translate
Translate strings for this package.
  • Field Details

    • BUNDLE_NAME

      private static final String BUNDLE_NAME
      The bundle holding the console's translated strings.
      See Also:
    • COUNTRY_BUNDLE_NAME

      public static final String 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 to Translate.
  • Method Details

    • getString

      public static String getString(String key, I2PAppContext ctx)
      Look up a string in this package's bundle.
      Parameters:
      key - the translation key, holding the English text when untranslated
      ctx - supplies the routerconsole.lang property, else current locale
      Returns:
      the translated string, or the key itself when no translation exists
    • getString

      public static String getString(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.
      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 the routerconsole.lang property, else current locale
      Returns:
      the translated string, with {0} replaced by the parameter
    • getString

      public static String getString(String s, Object o, Object o2, I2PAppContext ctx)
      Translate a string carrying two parameters.
      Parameters:
      s - string to be translated containing {0} and {1}
      o - first parameter, not translated
      o2 - second parameter, not translated
      ctx - supplies the routerconsole.lang property, else current locale
      Returns:
      the translated string, with {0} and {1} replaced
    • getString

      public static String getString(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.
      Parameters:
      n - the count, used to choose between s and p
      s - singular string, may contain {0} for the count
      p - plural string, may contain {0} for the count
      ctx - supplies the routerconsole.lang property, else current locale
      Returns:
      s or p, per the plural rules for n
    • getDisplayLanguage

      public static String getDisplayLanguage(String langCode, String dflt, I2PAppContext ctx)
      Return the "display language", e.g. "English" for the language specified by langCode, using the current language. Uses translation if available, then JVM Locale.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 language
      ctx - supplies the language to display the name in
      Returns:
      the display language