weimingtom / nekonme

Automatically exported from code.google.com/p/nekonme
0 stars 0 forks source link

[Patch] Add the "Capabilities.language" field to NME #250

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The attached patch adds the "language" property on the nme.system.Capabilities 
class. It returns the ISO 639-1 language code of the current platform.

It is implemented for the following targets:
 - HTML5 (returns navigator.language, tested on Chrome)
 - Flash (worked already, but now also when building with NME)
 - Windows (uses GetSystemDefaultUILanguage(), tested on Windows 7)
 - Android (uses Locale.getDefault().getLanguage(), tested on 4.0.4)
 - MacOS (uses NSLocale, UNTESTED)
 - iOS (uses NSLocale, UNTESTED)

It is NOT implemented for the following targets:
 - WebOS (returns null)
 - Blackberry (returns null)

I don't have the hardware to test on Mac OS and iOS right now, if you could 
check on those platforms, it'll be awesome.

Thanks!

Original issue reported on code.google.com by tyn...@gmail.com on 9 Jul 2012 at 4:27

GoogleCodeExporter commented 9 years ago
Of course, it's better if I provide the patch file as well. Sorry.

Original comment by tyn...@gmail.com on 9 Jul 2012 at 4:28

Attachments:

GoogleCodeExporter commented 9 years ago
Added. Thank you!

Original comment by joshuagr...@gmail.com on 10 Jul 2012 at 12:17

GoogleCodeExporter commented 9 years ago
I also implemented Linux in the following complementary patch. Works by getting 
the first 2 chars of the LANG environment variable.

Original comment by tyn...@gmail.com on 10 Jul 2012 at 8:24

Attachments:

GoogleCodeExporter commented 9 years ago
Please ignore the previous patch.

This one is based on r1768 and uses getenv("LANG"), then setlocale() as a 
fallback.

Original comment by tyn...@gmail.com on 10 Jul 2012 at 11:56

Attachments: