Multi-language management in Crazy Belts

posted in: Crazy Belts | 0

Today we have a post from Sergio Escanciano, our main programmer in Crazy Belts. He’s going to talk about one of the hardest tasks we had to confront recently: the localization of the game to many languages apart from Spanish and English. If you’re a gamedev and find yourself in the same place, don’t miss this article. We hope you can learn from his experience!

At first, Crazy Belts was a relatively small game that was going to be publshed in Spanish and English, being the localization made by our team. At the end of 2013, a novelty change the development of the game at every aspect: Crazy Belts was to be published in a lot of countries around the world, that’s why we needed to translate the game to a wide range of languages. Finally, the list was the following: Spanish, English, French, Italian, Russian, Chinese, Korean and Japanese.

The translation of the game strings to new languages was performed by other company, so for most languages we really didn’t need to do any notorious changes in the code. The big deal came out with the texts in Russian, Chinese, Korean and Japanese, because they used different alphabets so we needed differents text fonts to support their characters.

LibGDX, the framework we used in Crazy Belts, has the correct support of Asian and Cyrillic alphabets as a feature; so in that side the problem was solved. Also, from the side of game texts files, everything was solved because we used UTF-8 without BOM and all the characters are correctly encode.

options_cb

In the code, the first we did was to extract all the management and references of game fonts to one class. This change allowed us to modify them globally and at any point. Seizing it, the fonts were divided in some special cases, like score and countdown, because the numbers are displayed with the same font in every language.

Once this was done, we had to add the new fonts. In a first approach we tried to use just one font for these languages. We created then a new bitmap font from the font Code2000. At last, this solution was inadequate:

  • The font’s graphic design didn’t fit in the cartoon style of the game.

  • When generating all the characters of the four languages, the font’s size was huge (more than twenty character atlases). This problem came from the high number of characters from chinese and japanese.

  • Because of this size, the font load time significantly affected the game experience.

  • Despite the number of characters, there were some of them that didn’t show up, creating some incomplete texts and graphical issues.

To make the problem of the font’s load easy to understand, we are going to explain briefly how they are loaded in the game. Crazy Belts has four resource loads:

  1. An initial one when logos and load bar are displayed.

  2. While the logos and load screen are displayed, the common resources and game menus happen. The font of the current language (device language by default) is stored in the common assets.

  3. When the player enters in the game, the menus data are unloaded and the game data is loaded (infinite or story mode depending on what the player selects).

  4. When returning to the menu, the game data is unloaded and the menus data is loaded.

 

ruso_cb

Summarizing, all the fonts are loaded from the beginning. In Latin alphabets we had the memory charge measured, but in case of the languages that used the Code2000 their size mainly affected to low and middle range smartphones. After trying various solutions, we finally get to integrate one that solved the problems:

  1. We firstly selected, for each language, a font that fitted in the game’s graphic style.

  2. We did a modification to the tool for creating bitmap fonts, gdx-fontpack. This tool can generate bitmap fonts selecting only a reduced number of characters. This modification collected all the characters used by each language in the game strings, so we could reduce the atlas’ size until only by using the needed characters, finally leaving one atlas of about 500×500 pixels.

  3. A black border was added to the PNG font files from an image editor and they was compressed using the program optiPNG.

When we solved it, we had to implement one last feature.

In the game’s options screen there is the possibility to change the language, but this change was performed when reopening the game. That worked well, but in iOS we couldn’t give the possibility of close the game, because that was a task of the operative system. At the end, we had no certainty of when the game will be closed to begin the load of the new language.

To solve this we implemented the dynamic loading of languages. Each time a language is changed from the options screen, the current font is unloaded and the new one is loaded only if it’s necessary (as we commented before, between latin languages is not necessary). Finally, all the texts from the game menus are updated. It’s not necessary to refresh the game screen because its charge is done when the player enters those modes. Once we finished with it, we had this aspect of the game ready to the final version.

We hope you liked the post and can help some other people that have to confront the work of localizing a game in a lot of languages. Not an easy task indeed!

Leave a Reply