Class I18N

java.lang.Object
org.episteme.core.ui.i18n.I18N

public class I18N extends Object
Internationalization helper for Episteme UI.

Manages multiple resource bundles and provides centralized access to localized strings. Supports dynamic locale switching.

Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Method Details

    • getInstance

      public static I18N getInstance()
    • addBundle

      public void addBundle(String bundleBase)
      Registers an additional resource bundle base name.
      Parameters:
      bundleBase - the bundle base name (e.g., "org.episteme.core.ui.i18n.messages_natural")
    • setLocale

      public void setLocale(Locale locale)
      Sets the current locale and reloads all bundles.
      Parameters:
      locale - the new locale
    • addListener

      public void addListener(Consumer<Locale> listener)
    • removeListener

      public void removeListener(Consumer<Locale> listener)
    • getSupportedLocales

      public Locale[] getSupportedLocales()
      Gets the current locale.
      Returns:
      current locale
    • getLocale

      public Locale getLocale()
    • toggleLanguage

      public void toggleLanguage()
      Toggles between English and French.
    • get

      public String get(String key)
      Retrieves a localized string for the given key. Searches all registered bundles in order of registration.
      Parameters:
      key - the resource key
      Returns:
      the localized string, or the key itself if not found
    • get

      public String get(String key, String defaultValue)
      Retrieves a localized string for the given key, returning the default value if not found.
      Parameters:
      key - the resource key
      defaultValue - the value to return if key is missing
      Returns:
      the localized string or defaultValue
    • hasKey

      public boolean hasKey(String key)
    • get

      public String get(String key, Object... args)
      Retrieves a localized string with format arguments.
      Parameters:
      key - the resource key
      args - format arguments
      Returns:
      the formatted localized string
    • setTestMode

      public static void setTestMode(boolean enabled)