1 decade ago by nutbutter
Hello all,
So impact.js is just pure awesome! To make it better, I thought that I would share my localization code.
create a new file in
with the following code:
Then, in your
So impact.js is just pure awesome! To make it better, I thought that I would share my localization code.
create a new file in
lib/game/lang/load.jswith the following code:
ig.module( 'game.lang.load' )
.defines(function(){
enUS={
"MainMenu":[{
"Start": "Start",
"Options": "Options",
"Exit": "Exit"
}]
};
enUK={
"MainMenu":[{
"Start": "Begin",
"Options": "Settings",
"Exit": "Leave"
}]
};
});
Then, in your
main.js file make sure you add game.lang.load to your .requires and then in .defines add Lang = enUS. This makes it easy to switch between different languages on the fly. So wherever you render text, in the menu for instance, you can just call Lang.MainMenu[0]["Start"] and have it translate into whatever language you want! Easy peasy! 