Closed AlmasB closed 5 years ago
Foundation done in 0.4.0, now need game_language.properties
for in-game text and populate supported language.properties
Likely to be used via Local.add(lang, resource map<String, String>)
.
There are now semantically equivalent ways to add localization (supports both engine and game text):
1. getLocalizationService().addLanguageData(new Language("ENGLISH"), Map.of("some.key", "Hello World"));
OR
getLocalizationService().addLanguageData(Language.ENGLISH, Map.of("some.key", "Hello World"));
2. getLocalizationService().addLanguageData(Language.ENGLISH, assetLoader.loadResourceBundle("english.properties"));
Strings can be stored in a
.properties
file and loaded as aResourceBundle
withAssetLoader
. If two different locales use the same key set (as a normal Java app would), then we can usegetString()
in code, which would map to system locale file.Example:
File:
en.properties
exit = exit
File:
fr.properties
exit = quitter
File:
ru.properties
exit = выход
Then in the menu code something like:
The implementation of
getLocaleString()
should first read the system locale, then find a pre-defined properties file for that locale and retrieve the property. Probably best to use pre-defined file names from what Java locale property bundle gives us.