Post feature RSS Are you prepared to become international?

A brief article about how to make language localisation easy.

Posted by on

Since the beginning of the project we had a couple of things always clear:

1) We need to support more than one single language if we want to bring the game overseas.
2) We want to do the things properly. And this means scalable and modular enough to be expanded if needed.


- ...one level from world#2 (localisation on the gameover screen) -


Therefore we couldn't "hardcode" the texts and labels that appear on the game. So we were on the need of creating a localisation system in order to solve this feature we wanted.

This may seem at first something really complex to handle but in fact it isn't if you think carefully about it ;)

- Localisation in action 1... from English to Spanish -



- Localisation in action 2... from Spanish to English -



At the beginning we though several solutions but after some back and forth we figured out the one that fits better (in our opinion) with the architecture of the game. Beside this, the solution is flexible enough to be recycled and deployed in another project easily and seamlessly.

The solution was fairly simple:
We created a custom external file with a summary of the texts and words we use in our game and then we bind each one of those "strings" with one "codename"... something like this:



// Localisation_EN (ENGLISH language file):
#text1 = Welcome To the Castle! enjoy the game!.
#text2 = Find the KEY and reach the EXIT the fast you can...
#text3 = YES
#text3 = NO
...

// Localisation_ES (SPANISH language file):
#text1 = Bienvenido a To the Castle! Que te diviertas!.
#text2 = Encuentra la LLAVE y llega hasta la SALIDA lo más rápido que puedas...
#text3 = SI
#text3 = NO
...



Therefore, at the beggining of the game we can read this files and encode the entire file in something we call "dictionaries" that are mainly relational arrays.
Then, we created a fairly basic (but useful) function able to retrieve one string according to one of those codes using the "current language dictionary".

But we went a step beyond... As you well know, when you create a GUI you need something else than plain text and some times you have "sprites" or even "textures" that have some text on them.
So we decided to create a similar approach as with the "texts" in order to localize the GUI sprites if needed.

- A lot of localised button sprites -


The solutions here, is super simple and effective too (as you can see this is our leading dev. philosophy:P )
However, this time instead of creating a code_to_string dictionary we loaded the localized sprites on the project adding some suffixes depending on the language (_EN for English, _ES for Spanish, _FR for French and so on) then, each time that we load a "localised sprite" we do it using a special function that is able to locate and load the proper "sprite" according to the currently selected language on the game.

In the BETA we published few days ago you can see this actually working already.
In fact, you can check it easily going to the "game settings" section and changing the active language.

Hope you enjoyed the article,
See you on the next one!

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.