Class I18N


  • public final class I18N
    extends Object
    Singleton for the Internationalization (I18N)
    • Field Detail

      • JUMP

        public static final I18N JUMP
    • Method Detail

      • reset

        public static void reset()
      • setClassLoader

        public static void setClassLoader​(ClassLoader cl)
        Set the class loader used to load resource bundles, must be called by the PlugInManager (plugin jars are added to a child classloader there) to allow plugins to make use of this I18N class.
        Parameters:
        cl - the classLoader to set
      • setLocale

        public static void setLocale​(Locale localeNew)
        Set locale from string and (re)init
        Parameters:
        localeNew - the code for the lang and country locale to set
      • getLocale

        public static Locale getLocale()
      • setEncoding

        public static void setEncoding​(String csname)
      • getInstance

        public static I18N getInstance​(String categoryPrefix)
        Create & return the I18N instance for the given prefix
        Parameters:
        categoryPrefix - e.g. "my.cool.extension"
        Returns:
        I18N object for this category
      • getInstance

        public static I18N getInstance​(File path)
        Create & return the I18N instance for the given path
        Parameters:
        path - , some path in classpath e.g. new File('my/cool/extension/')
        Returns:
        I18N object
      • getInstance

        public static I18N getInstance()
        Return the default I18N singleton for OJ2 for use like I18N.getInstance().get()
        Returns:
        singleton I18N object for OpenJUMP
      • fromCode

        public static Locale fromCode​(String localeCode)
        utility method to convert a simplified locale string e.g. 'en_US' to a usable java.util.locale object
        Parameters:
        localeCode - a locale code String
        Returns:
        a Locale from the localeCode
      • applyToRuntime

        public static void applyToRuntime​(Locale loc)
        Utility method. Applies a given locale to the java runtime.
        Parameters:
        loc - the Locale to apply
      • getLocaleString

        public static String getLocaleString()
        Get the short signature for locale (letters extension :language 2 letters + "_" + country 2 letters)
        Returns:
        string signature for locale
      • getLanguage

        public static String getLanguage()
        Get the short signature for language (letters extension :language 2 letters) of the default instance
        Returns:
        string signature for language
      • getCountry

        public static String getCountry()
        Get the short signature for country (2 letter code) of the default instance
        Returns:
        string signature for country
      • get

        public String get​(String label,
                          Object... objects)
        Get the internationalized text from the resource bundle associated with the specified category or path. If no label is defined then a default string is created from the last part of the key. Supports re-usage of translations in default instance via '$J:' prefix. e.g. some.other.key = $J:reusable.generic.translation will be looked up and the content of reusable.generic.translation = some cool translation returned. Examples: categoryPrefixOrPathOrI18N instanceof I18N legacy option, mainly for the instance method this.getText(String) categoryPrefixOrPathOrI18N = new String("org.openjump.myplugin") then resourcebundle is looked up as /org/openjump/myplugin/language/jump[_locale].properties categoryPrefixOrPath = new File("language/wfs/messages") then resourcebundle is looked up as /language/wfs/messages[_locale].properties
        Parameters:
        label - Label with argument insertion : {0}
        objects - values of parameters contained in the key
        Returns:
        i18n label