Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: LocalizationService

[20:7] extends: EngineService

Wraps FXGL's LocalizationService, which translates string keys to the currently selected Language. Aussom users populate the service by calling addLanguageData with a Language and a key-value map (or a ResourceBundle), then switch languages via setSelectedLanguage. Translated strings are read with getLocalizedString. For UI bindings, localizedStringProperty returns a JavaFX StringBinding that updates automatically when the selected language changes.

Methods

  • LocalizationService (Ajo = null)

    Creates a LocalizationService wrapper. With no argument constructs a new empty FXGL LocalizationService; with an AussomJavaObject wraps an existing one (used by fxgl.getLocalizationService).

    • @p Ajo is an optional AussomJavaObject around a LocalizationService.
  • adopt (object Ajo)

    Wraps an existing LocalizationService AussomJavaObject.

    • @p Ajo is an AussomJavaObject around a LocalizationService.
    • @r A new wrapper.
  • setSelectedLanguage (object Lang)

    Sets the active language. Listeners on selectedLanguageProperty and any registered localizedStringProperty bindings fire.

    • @p Lang is a Language wrapper.
    • @r this object
  • getSelectedLanguage ()

    Returns the currently selected Language.

    • @r A Language wrapper.
  • addLanguageData (object Lang, Data)

    Populates the service with translations for the given Language from a (string key, string value) map.

    • @p Lang is a Language wrapper.
    • @p Data is a map of translation keys to translated strings.
    • @r this object
  • getLocalizedString (string Key)

    Returns the translation for the given key in the currently selected language. Returns "MISSING_KEY!" if the key has no translation, or "Language is NONE" if no language is selected.

    • @p Key is the translation key.
    • @r A string with the translation.
  • getLocalizedStringIn (string Key, object Lang)

    Returns the translation for the given key in the given language.

    • @p Key is the translation key.
    • @p Lang is a Language wrapper.
    • @r A string with the translation.
  • selectedLanguageProperty ()

    Returns the JavaFX ObjectProperty exposing the selected language; subscribe with a JavaFX ChangeListener to react to language switches.

    • @r An AussomJavaObject around an ObjectProperty.
  • localizedStringProperty (string Key)

    Returns a JavaFX StringBinding that yields the translation for the given key in the current language and updates automatically when the language changes.

    • @p Key is the translation key.
    • @r An AussomJavaObject around a StringBinding.
  • addLanguageDataBundle (object Lang, object BundleObj)

    Loads translations from a Java ResourceBundle, the standard locale-resource format produced by .properties files.

    • @p Lang is a Language wrapper.
    • @p BundleObj is an AussomJavaObject around a java.util.ResourceBundle.
    • @r this object
  • addLanguageDataLazy (object Lang, callback Cb)

    Loads translations lazily: the supplier callback is invoked only when the language is first selected, returning a map of translation keys to strings.

    • @p Lang is a Language wrapper.
    • @p Cb is a callback () -> map.
    • @r this object