Best Localized aproach for multiple languages

Best Localized aproach for multiple languages
0.0 0



I’m just developing my new game with cocos2d-html5 + js_bindigns, and I’m asking for developers who have managed to put multiple languages support on their game.

What’s the best approach for solve this problem on cocos2d-html5?

On iOs/Android it’s easy to have a localized folder with localized images/strings/etc…, can I do that on cocos2d-html5 and made the code works on every platform?.

I’m thinking of making a singleton class “LanguageManager” with some methods like:

~~getLocalizedImage(key) ->returns the image source

And have an xml file for each supported language and put all the resources under the res/lang.

What do you thing about this idea?

Just another question.

CCLabelBMP or CCLabelTTF? for having text localized. Having CCLabelBMP means that I need to know “all the characters” from a language I don’t understand, for example “chinese”, and made an image with this characters.

Maybe I can made an script that parses the “chinese.xml” utf8 chars and returns the chinese chars used on the file, so I can copy&paste does characters on GlypDesigner( and made the fnt file.

Any idea?

Do you thing this is good aproach for having this feature on cocos2d extensions? I could contribute to cocos2d with my code.

I apologiced for my english


Hi José,

The games I’ve done in HTML5 are not that big or text-intensive, at least to try a singleton class such as you specify. You could specify a file in the style of GameConfig.js of Moon Warriors, but for your translated texts:

// GameStrings.js
STRS = {}

STRS.intro_text = {
en: “Introduction”,
es: “Introduccion”,

STRS.title_img = {
en: “res/title-en.png”,
es: “res/title-es.png”,


var lang = cc.Aplication.getCurrentLanguage() == cc.LANGUAGE_SPANISH? es “en”;

Both ideas you give are pretty much the same to me. Remember that the difference between cc.LabelBMFont and cc.LabelTTF are more related to the performance, as with the TTF case you have the machine render all the text glyphs. It’s better in the end to have a good performance than having a smaller file (IMHO).


Thank’s for your recomendation.

I will use cc.LabelBMPFont rather than cc.LabelTTF.

Just a recomendation.

If you have plans for obfuscate your code, declare the arrays as show here.
// GameStrings.js
STRS = {}

STRS.intro_text = {
en “Introduction”,
es “Introduccion”,

STRS.title_img = {
en “res/title-en.png”,
es “res/title-es.png”,

Use (“”) on the keys of the array, because you are accessing the array with ([])