Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12457] iOS: Ti.Locale.currentLocale and currentCountry issues

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-11-10T21:35:37.000+0000
Affected Version/sRelease 3.1.0, Release 3.1.1, Release 3.2.0
Fix Version/sRelease 3.4.2, Release 3.5.0, Release 4.0.0
ComponentsiOS
Labelslocale, module_locale
ReporterThierry Godfroid
AssigneeMuhammad Dadu
Created2013-01-05T09:04:06.000+0000
Updated2014-11-25T01:51:37.000+0000

Description

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.

Comments

  1. jithinpv 2013-04-05

    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
  2. Jong Eun Lee 2013-12-27

    Issue reproduces. Tested with Ti 3.2.0.GA :(
  3. Ketan Majmudar 2014-04-29

    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:
       Countries.getCurrentLocale = function(){
           var lang, country, locale;
           lang = Ti.Locale.getCurrentLanguage();
           country = Ti.Locale.getCurrentCountry();
           locale = lang +"-"+ country;
           return locale;
       };
       
    It most certainly has a bug - Ti.Locale.getCurrentLocale will return *en-US* no matter what the language/region configuration of the device.
  4. Muhammad Dadu 2014-09-16

    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
       [ERROR] locale: en-US
       [ERROR] country: US
       [ERROR] language: en
       [ERROR] locale: en-US
       [ERROR] country: US
       [ERROR] language: en
       
  5. Olga Romero 2014-10-03

       [ERROR] :  locale: undefined
       [ERROR] :  country: undefined
       [ERROR] :  language: en
       [ERROR] :  locale: en-US
       [ERROR] :  country: US
       [ERROR] :  language: en
       
    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.
  6. Vishal Duggal 2014-11-10

    PR's merged master - https://github.com/appcelerator/titanium_mobile/pull/6106 3_4_X - https://github.com/appcelerator/titanium_mobile/pull/6331
  7. Ewan Harris 2014-11-25

    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.

JSON Source