2
\$\begingroup\$

I am loading my I18NBundle like this :

    assetManager.load("i18n/language", I18NBundle.class);
    assetManager.finishLoading();
    i18NBundle = assetManager.get("i18n/language", I18NBundle.class);

When I get(String key) the values of the german localization I get these symbols for the ü and ö characters. This is what it looks like when I use the debugger to see the mapped values :

enter image description here

In-game, it will display Huser instead of Häuser.

The french localization works fine with é and è. So I'm quite confused as why only the german localization fails.

\$\endgroup\$
2
\$\begingroup\$

To expand on Cedric's answer you should try these steps to make sore that the encoding is correct:

  1. Make sure that the properties file uses the correct encoding. It might help to delete and re-create the file in some cases.
  2. Make sure that the I18NBundle object uses the correct encoding. You do this by supplying the encoding when loading the bundle into the game:

    // Loading without asset manager
    I18NBundle.createBundle(baseFileHandle, encoding);
    
    // ex.
    I18NBundle.createBundle(Gdx.files.internal("game_en"), "UTF-8")
    
    // Loading with asset manager.
    I18NBundleParameter param = new I18NBundleParameter(locale, encoding);
    manager.load(fileName, I18NBundle.class, param);
    
    // ex.
    // null means it uses Locale.getDefualt()
    I18NBundleParameter param = new I18NBundleParameter(null, "UTF-8");
    manager.load("game_en", I18NBundle.class, param);
    

    Note that UTF-8 is the default encoding for the I18NBundle and Locale.getDefault() is the default locale, so if you're going to use UTF-8 you don't have to change the encoding and if you're going to use Locale.getDefault() you don't have to change the locale.

  3. If none of this works make sure your font supports your characters! Too often have I made the mistake of using a font that doesn't include special characters just to notice this during the I18N process.

\$\endgroup\$
0
\$\begingroup\$

Simply deleting my language_de.properties file and pasting the content back in worked. It may have been an encoding issue.

\$\endgroup\$
0
\$\begingroup\$

I had the same problem because language.properties file had been created in ANSI encoding and LibGDX uses UTF-8 by default, using notepad ++ I converted the file from ANSI to UFT-8

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.