Implementing Localization on UI

Good day all jMonkey’s,

Today I have been thinking on how I would implement localization for my text in game.
I was thinking of implementing some sort of *.properties file for different localizations which will
contain a key and a text value for different text.
Then in game, I do a lookup for the specific key to get the text value.

I am creating the post to have a discussion of how and what is the prefered way of doing it in jME.

1 Like

I’m using Java native. ResourceBundles. Which is exactly what you describe, key and text value. For me also the choice is clear as NiftyGUI supports ResourceBundles straight.

But even if your UI doesn’t, using native ResourceBundles might help you with the basics. Especially now that with newer Javas everything is finally UTF-8 and no need to escape the ResourceBundles.

1 Like

Cool, thanks for the response.
Do you maybe have a good reference for me to read up on?

1 Like

Our code is open source, GitHub - tonihele/OpenKeeper: Dungeon Keeper II remake (uses resource bundles). I’m not sure if that is what you meant. Java API documentation is good and perhaps here is a general how-to https://www.baeldung.com/java-resourcebundle.

3 Likes

First of all , youshould have a bitmap font, our wiki has an instruction you should follow.
Then , you should read this java tutorial
BTW
Java use UTF-16 instead UTF-32 or UTF-8, UTF-8 chars are packed into UTF-16.

2 Likes

Here is a simple implementation of my own.

  1. The language files hold all the Strings.

src/main/resource/lang_en.properties

  1. A class to load and switch language.
  1. UI text it get by i18n.getString(key)
  1. You can switch the language by yourself
3 Likes

Wow, that simple.
Thanks for sharing.

2 Likes