plicatibu Posted May 9, 2014 Share Posted May 9, 2014 Hi. Anyone here could me point a good tutorial on how to localize my game (using external files). The ones I found on Google are not good (or maybe I'm so dumb to understand ) Thank you. Quote Link to comment Share on other sites More sharing options...
ultimatematchthree Posted May 16, 2014 Share Posted May 16, 2014 One approach is to create a JavaScript object for each language you want to support, whose keys could be an identifier for a certain string, and whose corresponding value would be that string written in that language. For example:var english = {};var spanish = {};english["greet"] = "hello";spanish["greet"] = "hola";var currentLanguage = english; // or spanishrenderText(currentLanguage["greet"]); // should show text in appropriate languageYou can even pick a "primary" language and use that language for the keys, such that english["hello"] == "hello" and spanish["hello"] == "hola". This can be made more robust of course, e.g. falling back to the key or the primary language translation if the key doesn't exist, etc. but you can follow the basic principles here. And regarding external files, the contents of your "language" objects can come from external JSON files, for example. Quote Link to comment Share on other sites More sharing options...
plicatibu Posted May 17, 2014 Author Share Posted May 17, 2014 Hi. Thank you for replying. I'm trying to load external JSON files on Phgaser but I'm facing a problem as I posted here. Regards. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.