Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12467] iOS: Locale.currentLanguage not returning 2 letter code- ISO 639-1 for chinese language

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2017-06-22T20:23:40.000+0000
Affected Version/sRelease 3.0.0, Release 3.2.0, Release 3.2.1
Fix Version/sn/a
ComponentsiOS
LabelssupportTeam
ReporterNikhil Sharma
AssigneeEric Merriman
Created2013-01-29T02:05:13.000+0000
Updated2017-06-22T20:23:40.000+0000

Description

Ti.Locale.currentLanguage is not returning 2 letter code - ISO 639-1 as per our documentation http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Locale-property-currentLanguage and apple's documentation https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPInternational/Articles/LanguageDesignations.html It is returning "zh-Hans" when you set the language of your device to chinese.

Actual Result

It is returning "zh.Hans"

Expected Result

It should return "zh"

Repo Steps

1. Include the below testcase in your project's app.js 2. Set the language of your device to Chinese. 3. Open the app and click the show button. 4. It'll show "zh-Hans" in the text area.
var win = Titanium.UI.createWindow();
win.backgroundColor = '#EEE';

var show = Ti.UI.createButton({
	title : 'Show',
	left : 90,
	top : 10,
	width : 140,
	height : 45,
	fontSize : 20
});

var ta = Ti.UI.createTextArea({
	top : 110,
	left : 10,
	width : 300,
	height : 180,
	backgroundColor : 'white',
	fontSize : 18
});

win.add(show);
win.add(ta);

show.addEventListener('click', function() {
	ta.value = "Show current language:" + Ti.Locale.getCurrentLanguage();
});
win.open();

Attachments

FileDateSize
iOS Simulator Screen shot Feb 23, 2014 11.24.27 AM.png2014-02-23T05:35:35.000+000027426

Comments

  1. Lee Morris 2017-06-22

    I am unable to reproduce this issue with the following environment; iPhone 7 (10.2) Studio 4.9.0.201705302345 Ti SDK 6.1.1.v20170620103414 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.8.0_131

JSON Source