FXGL
FXGL copied to clipboard
Getting excetion when setting selected language in LocalizationService
Hello,
I have some using setting the language of the LocalizationService. Whe adding the following method to the class LocalizationSample:
@Override
protected void onPreInit() {
getLocalizationService().addLanguageData(Language.ENGLISH, ResourceBundle.getBundle("assets.texts.texts", Locale.ENGLISH));
getLocalizationService().setSelectedLanguage(Language.ENGLISH);
}
an exception is thrown:
java.lang.RuntimeException: A bound value cannot be set.
at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:143)
at javafx.base/javafx.beans.property.ObjectProperty.setValue(ObjectProperty.java:78)
at com.almasb.fxgl.core@17/com.almasb.fxgl.localization.LocalizationService.setSelectedLanguage(LocalizationService.kt:37)
I am facing the same issue when trying to change the language from other points in the code. How can the language be changed properly?
Thanks
Hi,
all runtime changes normally go through getSettings(). Try this:
getSettings().getLanguage().setValue(...);
Let me know if it works.
Yes thanks it did. This, however, raised another question I will ask in another issue