Localization for iOS devices

losh

  • Posts: 28

« Last Edit: July 17, 2015, 06:35:28 pm by losh »

Jon

  • *
  • Posts: 17516
A crude but simple way to do this would be to store all game text in a list game attribute and then have the game pull all its text from that.

Switching the language would then be simply switching which game attribute you're pulling the text from.

FortySe7en

  • Posts: 304
But how would you be able to determine what's device's language?
Other than that, using list and then putting IDs of strings that would be fetched seems like a good idea, although a bit hard to manage (unless there is some easy way I could open the list attribute in Excel or at least as an XML?). Where could I find such list as a file in my stencyl game?

bonzero

  • Posts: 487
I would love to know if that was possible too, just to know the iOS language of that device to automatically set up the correct language (using list etc as Jon says)

Jon

  • *
  • Posts: 17516
The assumption when I made the post was to have the user switch the language in-game. It's not too hard to put up a screen on the first launch to let you pick out the language. Not as ideal as auto (which would require either a built in block or an extension), but it's a simple solution.

h1rnz1lla

  • *
  • Posts: 649
i did it with 2.2 already. pulling the device language is 2 lines of code,but with 3.0 we need someone making a extension out of it, im not able to do this.

bonzero

  • Posts: 487
So I assume that there's no haxe code for that. I would prefer the automatic option but creating a language selection screen is not bad either

Innes

  • *
  • Posts: 1963
I might be misunderstanding the requirement, but you can use the nme.system.Capabilities class to return the language of the device. I've tested this on iOS and it works just fine (returns en-GB for me); see the attached image for a sample of how to recover the device's language setting.

Just grab the language, and use an IF test to display the appropriate language. My preference is to reference a list based on the result of the test, but don't forget to return a default language if the language code isn't recognised in the test.

The Capabilities class has some interesting stuff in it, but be aware that not all the information is available across all platforms.

http://lib.haxe.org/d/nme/3.4.3/nme/system/Capabilities

Hope that helps.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

bonzero

  • Posts: 487
that's exactly what we were after I think, I will check your solution later and have a look at that lib.haxe.org it seems to contain the type of information I was looking for other times. Massive thanks Innes

h1rnz1lla

  • *
  • Posts: 649
wow innes, thats pretty cool. awesome. thats the stuff we need more of. small code snipets that are easy to understand and super usefull. cool.

Innes

  • *
  • Posts: 1963
You're welcome guys - I'm glad you found it useful (and hope that it works as expected).

It would be great to see how it is implemented in practice. I have some ideas, but I have another big project to finish-off first (the Stencyl book)!

I love to find solutions like this, but I have a steep-learning curve ahead - even though I am a fairly competent AS3 coder, and haxe nme is heavily based on AS3, my main task ahead is understanding how it all integrates with Stencyl.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

bonzero

  • Posts: 487
Innes if you cover the haxe aspects of stencyl and some code like that I will buy that book on day one

h1rnz1lla

  • *
  • Posts: 649
yeah i think a really basic tutorial on how to integrate haxe code or even simple snipets like that, would help a lot of people!

Innes

  • *
  • Posts: 1963
Innes if you cover the haxe aspects of stencyl and some code like that I will buy that book on day one

Thanks for the vote of confidence, but the book is targeted at beginners.

Maybe if this book is a success, I'll look at doing a follow-up for advanced users. I have a suspicion that the market would be too narrow though!
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

bonzero

  • Posts: 487
yes, you are right, I think it makes more business sense that way, an idea that just came to mind is to make a reference app about snippets of haxe code for stencyl, something that the mid-advanced users might find useful