Open hansnf opened 9 months ago
This might help:
Create a target_language_name.lang
file in /assets/languages/
. See example
Add the target language as a supported language:
settings.getSupportedLanguages().add(...);
Use bindings where localization is needed:
FXGL.localizedStringProperty("some.key")
returns a StringBinding which you can use with most JavaFX UI objects to bind their text property, so that when you change the language via getSettings()
, all bound properties will be updated to display the localized text.
I have a rather general question about the usage of menu. For illustrating my issue, I will refer to a modified example of the Internationalization example provided by the FXGL repo. The sample makes use of a very simple menu. I have two questions: 1) When I use the code as it is, the key "some.key" is not available within the MainMenu. Where is a good point to initalize the keys 2) I consider creating a menu element to select the language in the MainMenu. When the language changes I can redraw all elements in the main menu. However, other menus such as the in-game menu are not updated automatically. What is the suggested way to do this? I was thinking about working with messages or restart the whole game.
Thank you very much!