Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3680] Windows: Ti.Locale.getString()/L() does not reflect Ti.Locale.setLanguage()

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2016-06-02T16:20:37.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterJonas Bjurhult
AssigneeShak Hossain
Created2016-06-01T08:35:11.000+0000
Updated2016-06-02T16:20:37.000+0000

Description

Setting language via Ti.Locale.setLanguage() changes language in the app, but it does not affect the language returned in Ti.Locale.getString()/L()like on iOS or Android. The following code shows the problem: index.js
Ti.Locale.setLanguage('en');
Ti.API.info('current language is: ' + Ti.Locale.getCurrentLanguage());
Ti.API.info('before change ' + L('test'));
Ti.Locale.setLanguage('sv');
Ti.API.info('new language is: ' + Ti.Locale.getCurrentLanguage());
Ti.API.info('after change ' + L('test'));
i18n/en/strings.xml
<?xml version="1.0" encoding="UTF-8"?><resources>
	<string name="test">This is a test string in English</string>
</resources>
i18n/sv/strings.xml
<?xml version="1.0" encoding="UTF-8"?><resources>
	<string name="test">This is a test string in Swedish</string>
</resources>

Comments

  1. Nazmus Salahin 2016-06-02

    Hello, I am able to reproduce this issue with given code and given steps. *Steps:* 1. Create a default classic project for Windows Phone. 2. Replace the app.js file with following code.
       
       var win= Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
       
       win.open();
       
       
       Ti.Locale.setLanguage('en');
       
       Ti.API.info('current language is: ' + Ti.Locale.getCurrentLanguage());
       
       Ti.API.info('before change ' + L('test'));
       
       Ti.Locale.setLanguage('sv');
       
       Ti.API.info('new language is: ' + Ti.Locale.getCurrentLanguage());
       
       Ti.API.info('after change ' + L('test'));
       
       
    3. Create i18n/en and i18n/sv folder. 4. In the i18n/en create strings.xml file with following content.
       <?xml version="1.0" encoding="UTF-8"?><resources>
       
       	<string name="test">This is a test string in English</string>
       
       </resources>
       
    5. In the i18n/sv create strings.xml file with the following content.
       <?xml version="1.0" encoding="UTF-8"?><resources>
       
       	<string name="test">This is a test string in Swedish</string>
       
       </resources>
       
       
    4. Build and run the app . Following log is produced.
       [INFO] :   current language is: en
       [INFO] :   before change This is a test string in English
       [INFO] :   new language is: sv
       [INFO] :   after change This is a test string in English
       
    Thanks *Environment*: *OS :* Microsoft Windows 8.1 Enterprise N *Device info:* Microsoft Lumia 640 (Windows Phone 8.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.4.0.v20160429102159 *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.2 *Appcelerator Studio:* 4.5.0
  2. Sharif AbuDarda 2016-06-02

JSON Source