Localization for iOS devices

Jon

  • *
  • Posts: 17516
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.


Thanks for pointing this out. I'l'l wrap that into a block.

Innes

  • *
  • Posts: 1963
Thanks for pointing this out. I'l'l wrap that into a block.

That would be great. Will it be a 'native' Stencyl block, or an extension?

I'd quite like to see some more examples of extensions; I'm nearly at the stage when I can start to really try out 'new stuff', rather than spending 95% of my free time on the book!
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Jon

  • *
  • Posts: 17516
Native block.

There are a fair amount of pure haxe extensions out there. But native I haven't seen anything yet because it requires a bit more digging in and also knowing either Java or Objective-C.

The revised extensions guide is here.
http://www.stencyl.com/help/view/how-to-create-engine-extension/

losh

  • Posts: 28
I am going to produce a game showing how this will work, but you cannot use this in iOS though...

Looking forward to the extension.

h1rnz1lla

  • *
  • Posts: 649
sorry to necromance this thread, is there anyone who could make an extension for this? it's not working on iOS.

Jon

  • *
  • Posts: 17516
@Innes - This appears to crash on iOS but works fine on Flash. Is there an alternate approach?

Innes

  • *
  • Posts: 1963
I don't know of another way (I've not looked for an alternative solution). My Mac is boxed up at the moment, so I'm not in a position to try anything else right now.


I wonder why it's crashing? I definitely tested the code on an iOs device. Could it be something trivial like the data type returned? Perhaps try putting it in an [anything as text] block.


Sorry I can't be more helpful at the moment.
Visit www.TheStencylBook.com - the only published book for learning Stencyl.

Jon

  • *
  • Posts: 17516
Simply accessing it causes a crash, even before anything else is done. Implicitly looks like something under the hood is happening that it doesn't like.

Code: [Select]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                0x033ed0b0 objc_msgSend + 36
1   CoreFoundation                0x0312241c CFRelease + 108
2   CoreFoundation                0x03127d8c __CFTypeCollectionRelease + 44
3   CoreFoundation                0x03127d0e __CFArrayReleaseValues + 446
4   CoreFoundation                0x03127b3e __CFArrayDeallocate + 30
5   CoreFoundation                0x031224f0 CFRelease + 320
6   libobjc.A.dylib                0x033ee0c3 objc_release + 51
7   libobjc.A.dylib                0x033eebd9 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 555
8   CoreFoundation                0x03148468 _CFAutoreleasePoolPop + 24
9   Foundation                    0x01e24f1d -[NSAutoreleasePool drain] + 149
10  1 Test                        0x0013b32b nme::CapabilitiesGetLanguage() + 219
11  1 Test                        0x00054443 nme_capabilities_get_language() + 19
12  1 Test                        0x004d71d6 ExternalPrimitive::__run() + 118
13  1 Test                        0x001e8949 neash::system::Capabilities_obj::nmeGetLanguage() + 57

Max Finch

  • *
  • Posts: 2180
2 years later and we're still getting a crash? Except now it's openfl.system.Capabilities.language

I'm really going to need native way to localize my new game, any chance for a fix?

Justin

  • *
  • Posts: 4007
Looks like it's an issue with the current lime version. Updating should fix this.

https://github.com/openfl/openfl/issues/464

I'll update within the next couple of days.

For Live Support: Join our discord channel and ping me @justin.

Max Finch

  • *
  • Posts: 2180
Thanks man, let me know when this has been updated?


Max Finch

  • *
  • Posts: 2180
Still checking to see if lime has been updated?


Max Finch

  • *
  • Posts: 2180
If nobody is going to answer me on this, can I at least know where the affected file is in Stencyl so I can fix it myself?