Ti.Locale issue
Ti.Locale is NOT working as expected after reading the doc.
Expected
currentLocale and getCurrentLocale() to work like language i.e.
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Locale-method-getCurrentLocale
Repro sequence
Ti.API.error("locale: " + Ti.Locale.currentLocale);
Ti.API.error("country: " + Ti.Locale.currentCountry);
Ti.API.error("language: " + Ti.Locale.currentLanguage);
Ti.API.error("locale: " + Ti.Locale.getCurrentLocale());
Ti.API.error("country: " + Ti.Locale.getCurrentCountry());
Ti.API.error("language: " + Ti.Locale.getCurrentLanguage());
returns
[ERROR] locale: undefined
[ERROR] country: undefined
[ERROR] language: fr
[ERROR] locale: fr-BE
[ERROR] country: BE
[ERROR] language: fr
yet another console output
[ERROR] : locale: undefined
[ERROR] : country: undefined
[ERROR] : language: en
[ERROR] : locale: en-US
[ERROR] : country: US
[ERROR] : language: en
I am not competent enough in objective-C and mobile SDK knowledge but the implementation of locale module here looks fishy to me (I would expect implementations for currentLocale and currentCountry). I tested w/ SDKs 1.8.2, 2.1.2.GA and 3.0.0.GA on Mac OSX for iOS.
Issue reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 iOS iPhone Simulator: iOS SDK version: 6.0
Issue reproduces. Tested with Ti 3.2.0.GA :(
I have been working on a project for European Nordics markets and this method not working caused a lot of debugging and eventually having to concatenate my own version of this:
It most certainly has a bug - Ti.Locale.getCurrentLocale will return *en-US* no matter what the language/region configuration of the device.
PR: https://github.com/appcelerator/titanium_mobile/pull/6106 Added the two missing properties to the SDK that were referenced in the docs. Testing sample code after implementation
Tested using Mac osx 10.9.5 Mavericks Appcelerator Studio, build: 3.4.0.201409261245 Titanium SDK, build: 3.4.1.v20141003114920 acs@1.0.18 alloy 1.5.1 install@0.1.7 npm@1.4.23 sudo@1.0.3 titanium 3.4.0 titanium-code-processor@1.1.1 Xcode6.1GM Device: iPhone 6 iOS 8.1 Closing as fixed.
PR's merged master - https://github.com/appcelerator/titanium_mobile/pull/6106 3_4_X - https://github.com/appcelerator/titanium_mobile/pull/6331
Verified fix on: Mac OSX 10.10.1 Appcelerator Studio, build: 3.4.1.201410281743 Titanium SDK build: 3.5.0.v20141124114114, 3.6.0.v20141124111716 Titanium CLI, build: 3.4.1 Alloy: 1.5.1 Xcode 6.2 beta iPhone 6 Plus (8.1), iPhone 6 Simulator (8.2) Using the test case provided, built to both simulator and device and launched the app multiple times while changing the location and language in the settings. Closing ticket.