4

I'm in the middle of finishing my libGDX android game and I have problems with making localizations.

I want my game to be localized in Polish, English, Arabic and Chinese. To do this, I'm using libgdx I18NBundle which works perfectly fine. I have no problems with the former 2, they print very well with my BitmapFont(I've made it through Hiero).

I have completely no idea how to render the latter 2. Hiero doesn't seem to be capable of generating bitmaps from non-western fonts, and trying Gdx freetype extension left me even more confused(printing western symbols didn't work - another characters where showing and when I was trying to print Chinese/Arabic characters all I got was blank space).

Here's the second part of the question. Let's assume that I/we managed to achieve working font rendering. It's quite obvious that I'm going to need 3 fonts(Polish/English, Chinese and Arabic). I have to somehow detect system's language and then load proper font. Loading proper font doesn't seem like a big problem, the problem is, how I could detect the language(not whole locale).

Kierek93
  • 127
  • 2
  • 8

2 Answers2

1
  1. Hiero generates bitmap font for non-western fonts. I generated several Cyrillic bitmap fonts for my games. And I tried several arabic fonts from this page just now - all work pretty well. Probably you should ask another question with more detailed description of your problems with Hiero.

  2. You can use method Locale.getDefault().getLanguage() (more info here) in your AndroidLauncher class to get current language on device at runtime.

Then your should decide what language from your localizations you will use and pass this info to the main game class.

protected void onCreate (Bundle savedInstanceState) {
    ...
    String sysLang = Locale.getDefault().getLanguage();
    String i18nLang;
    if ((sysLang == "en") || (sysLang == "de")) {
        i18nLang = "en";
    } else if (...) {...}

    initialize(new MyGame(i18nLang), config);
}
Community
  • 1
  • 1
Rara
  • 639
  • 9
  • 22
0

If you select the font file manually, it will work. Apparently the non-western fonts in the default System list won't work in Hiero.

enter image description here

Neerkoli
  • 2,423
  • 3
  • 16
  • 21