java.lang.Object
io.github.palexdev.mfxlocalization.I18N

public class I18N extends Object
Class to handle internationalization.

To change the project's language you should use setLanguage(Language) before loading any node (for example at the top of the Application.start(Stage) method).

  • Property Details

    • locale

      public static javafx.beans.property.ObjectProperty<Locale> localeProperty
      Specifies the current MaterialFX language.

      NOTE: it is not recommended to set the Locale from this property, you should use the given setter, setLanguage(Language), since MaterialFX may not support all Locales.
      See Also:
  • Constructor Details

    • I18N

      public I18N()
  • Method Details

    • get

      public static String get(String key, Object... args)
      Returns:
      the String associated with the given key. The resource bundle used is loaded from the current specified locale, localeProperty()
    • get

      public static String get(Language language, String key, Object... args)
      Returns:
      the String associated with the given key. The resource bundle used is loaded from the specified language parameter
    • getOrDefault

      public static String getOrDefault(String key, Object... args)
      Returns:
      the String associated with the given key. The resource bundle used is loaded from the current specified locale, localeProperty() If the bundle doesn't provide any value for the given key, returns the value from the default language, Language.defaultLanguage()
    • getOrDefault

      public static String getOrDefault(Language language, String key, Object... args)
      Returns:
      the String associated with the given key. The resource bundle used is loaded from the specified language parameter. If the bundle doesn't provide any value for the given key, returns the value from the default language, Language.defaultLanguage()
    • getOrDefault

      public static String getOrDefault(String key, String def, Object... args)
      Returns:
      the String associated with the given key. The resource bundle used is loaded from the current specified locale, localeProperty() If the bundle doesn't provide any value for the given key, returns the given def parameter
    • getOrDefault

      public static String getOrDefault(Language language, String key, String def, Object... args)
      Returns:
      the String associated with the given key. The resource bundle used is loaded from the specified language parameter. If the bundle doesn't provide any value for the given key, returns the given def parameter
    • getBinding

      public static javafx.beans.binding.StringBinding getBinding(String key, Object... args)
      Returns:
      a StringBinding that updates whenever the localeProperty() changes. The localized String is loaded using getOrDefault(String, Object...)
    • getBinding

      public static javafx.beans.binding.StringBinding getBinding(Callable<String> callable)
      Returns:
      a StringBinding that updates whenever the localeProperty() changes. The value is computed according to the given Callable
    • getLocale

      public static Locale getLocale()
      Gets the value of the locale property.
      Property description:
      Specifies the current MaterialFX language.

      NOTE: it is not recommended to set the Locale from this property, you should use the given setter, setLanguage(Language), since MaterialFX may not support all Locales.
      Returns:
      the value of the locale property
      See Also:
    • localeProperty

      public static javafx.beans.property.ObjectProperty<Locale> localeProperty()
      Specifies the current MaterialFX language.

      NOTE: it is not recommended to set the Locale from this property, you should use the given setter, setLanguage(Language), since MaterialFX may not support all Locales.
      Returns:
      the locale property
      See Also:
    • setLanguage

      public static void setLanguage(Language language)
    • getSupportedLanguages

      public static Language[] getSupportedLanguages()
      Returns:
      all the supported languages
    • getBundleBaseName

      public static String getBundleBaseName()
      Returns:
      the ResourceBundle's base name