{ "id": "172430", "key": "TIMOB-26477", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-10-23T20:31:56.000+0000", "created": "2018-10-12T09:30:58.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-11-05T22:58:39.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "In Arabic mode, the locale should change the layout correctly like window-title to the right, home-up button on right as well. All RTL effects should be applied.\r\n\r\nHowever, using Ti.Locale the Arabic or RTL changes do not take place. If we use below code to apply Arabic language using Ti.Locale, the only changes that are taking place the Alert Dialog buttons are switched, but title, home-up button position, pickers are still unaffected, and it's incorrect behaviour as opposed to native Android app.\r\n\r\n*Full titanium code using Ti.Locale(not-working) and Hyperloop(working)*\r\n{code:java}\r\n\r\nvar ios_nav;\r\n\r\nvar indexWindow = Ti.UI.createWindow({\r\n backgroundColor : 'white',\r\n title : 'Language Changes',\r\n layout : 'vertical'\r\n});\r\n\r\nvar btn1 = Ti.UI.createButton({\r\n title : 'Set English using Ti.Locale',\r\n top : 10,\r\n width : Ti.UI.SIZE\r\n});\r\nbtn1.addEventListener('click', function () {\r\n Ti.Locale.setLanguage('en');\r\n showAlert();\r\n});\r\n\r\nvar btn2 = Ti.UI.createButton({\r\n title : 'Set Arabic using Ti.Locale',\r\n top : 10,\r\n width : Ti.UI.SIZE\r\n});\r\nbtn2.addEventListener('click', function () {\r\n Ti.Locale.setLanguage('ar');\r\n showAlert();\r\n});\r\n\r\nvar btn3 = Ti.UI.createButton({\r\n title : 'Set English using Hyperloop',\r\n top : 40,\r\n width : Ti.UI.SIZE\r\n});\r\nbtn3.addEventListener('click', function () { changeByHyperloop('en') });\r\n\r\nvar btn4 = Ti.UI.createButton({\r\n title : 'Set Arabic using Hyperloop',\r\n top : 10,\r\n width : Ti.UI.SIZE\r\n});\r\nbtn4.addEventListener('click', function () {changeByHyperloop('ar') });\r\n\r\nvar btn5 = Ti.UI.createButton({\r\n title : 'Open new Window to see changes',\r\n top : 50,\r\n width : Ti.UI.SIZE\r\n});\r\nbtn5.addEventListener('click', openNewWindow);\r\n\r\nindexWindow.add(btn1);\r\nindexWindow.add(btn2);\r\nindexWindow.add(btn3);\r\nindexWindow.add(btn4);\r\nindexWindow.add(btn5);\r\n\r\nif (OS_IOS) {\r\n ios_nav = Ti.UI.iOS.createNavigationWindow({ window : indexWindow });\r\n ios_nav.open();\r\n\r\n} else {\r\n indexWindow.open();\r\n}\r\n\r\nfunction showAlert(e){\r\n Ti.UI.createAlertDialog({\r\n cancel : 1,\r\n buttonNames: ['RIGHT', 'LEFT'],\r\n message: 'App language is ' + (Ti.Locale.currentLanguage == 'en' ? 'English' : 'Arabic'),\r\n title: 'Dialog Title'\r\n }).show();\r\n}\r\n\r\nfunction changeByHyperloop(language) {\r\n if (OS_ANDROID) {\r\n var Activity = require('android.app.Activity');\r\n var Configuration = require('android.content.res.Configuration');\r\n var Locale = require('java.util.Locale');\r\n var activity = new Activity(Ti.Android.currentActivity);\r\n\r\n var myLocale = new Locale(language);\r\n Locale.setDefault(myLocale);\r\n\r\n var config = new Configuration();\r\n config.locale = myLocale;\r\n\r\n // this doesn't work completely like moving scroll-bars and titles to right-edge.\r\n // seems Ti.Locale.setLanguage() also using Application-Context which doesn't work properly on layout-direction\r\n // var ctx = activity.getApplicationContext();\r\n\r\n // this is working fine by applying all layout and directional changes properly\r\n var ctx = activity.getBaseContext();\r\n ctx.getResources().updateConfiguration(config, ctx.getResources().getDisplayMetrics());\r\n\r\n showAlert();\r\n\r\n } else {\r\n alert('Hyperloop code not available on iOS. Please use Ti.Locale buttons to test language changes');\r\n }\r\n}\r\n\r\nfunction openNewWindow() {\r\n var win = Ti.UI.createWindow({\r\n backgroundColor : 'white',\r\n title : Ti.Locale.currentLanguage == 'en' ? 'English Language' : 'Arabic Language',\r\n layout : 'vertical'\r\n });\r\n\r\n if (OS_IOS) {\r\n win.backButtonTitle = '';\r\n\r\n win.add(Ti.UI.createLabel({\r\n top : 20,\r\n left : 20,\r\n right : 20,\r\n textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER,\r\n color : 'black',\r\n text : \"New window opening transition animation is from right-to-left in English language.\\n\\nBut it should be left-to-right in Arabic language which it is not.\\n\\nAlso the back-arrow icon should be on different sides in both language.\\n\\nSo it's a bug on iOS also.\"\r\n }));\r\n\r\n } else {\r\n var picker = Ti.UI.createPicker({\r\n left : 20,\r\n right : 20,\r\n top : 20\r\n });\r\n\r\n var data = [];\r\n data[0]=Ti.UI.createPickerRow({title:'Bananas'});\r\n data[1]=Ti.UI.createPickerRow({title:'Strawberries'});\r\n data[2]=Ti.UI.createPickerRow({title:'Mangos'});\r\n data[3]=Ti.UI.createPickerRow({title:'Grapes'});\r\n\r\n picker.add(data);\r\n win.add(picker);\r\n\r\n win.add(Ti.UI.createLabel({\r\n top : 20,\r\n left : 20,\r\n right : 20,\r\n textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER,\r\n color : 'black',\r\n text : 'Picker caret icon should be on right-side in English language and on left-side in Arabic language'\r\n }));\r\n\r\n win.addEventListener('open', function () {\r\n var actionBar = win.activity.actionBar;\r\n actionBar.displayHomeAsUp = true;\r\n actionBar.title = \"Language Demo\";\r\n actionBar.onHomeIconItemSelected = function() {\r\n win.close();\r\n };\r\n });\r\n }\r\n\r\n OS_IOS ? ios_nav.openWindow(win) : win.open();\r\n}\r\n{code}\r\n\r\nThe layout changes works all correctly ONLY using Hyperloop which replicates the native Android code.\r\n\r\nIn this full sample code, using Ti.Locale, the alert-buttons are changing their positions, but title stays on left-edge in both Arabic and English language. But through Hyperloop or native Android, alert-title move to right-edge and so does the picker which is correct behaviour.\r\n\r\nAfter reviewing the Ti.Locale.setLanguage() method code, I was able to get only one hint that Ti SDK code is using application-context and my native Android or Hyperloop code works when using Activity's base-context.\r\n\r\nI do not know how to do this in iOS using Hyperloop, but I hope you get the issue.", "attachment": [ { "id": "65704", "filename": "Android-Alert-ar.png", "author": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-12T09:24:48.000+0000", "size": 27781, "mimeType": "image/png" }, { "id": "65702", "filename": "Android-Alert-en.png", "author": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-12T09:24:48.000+0000", "size": 27649, "mimeType": "image/png" }, { "id": "65703", "filename": "Android-List-ar.png", "author": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-12T09:24:48.000+0000", "size": 48333, "mimeType": "image/png" }, { "id": "65701", "filename": "Android-List-en.png", "author": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-12T09:24:49.000+0000", "size": 46784, "mimeType": "image/png" } ], "flagged": false, "summary": "Ti.Locale.setLanguage is not applying the locale effects properly on Android & iOS", "creator": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "prashant_saini", "key": "prashant_saini", "displayName": "Prashant Saini", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Ti SDK - 7.4.0.GA\r\nAndroid 8.1.0\r\niOS 11", "closedSprints": [ { "id": 1088, "state": "closed", "name": "2018 Sprint 22", "startDate": "2018-10-21T23:20:52.653Z", "endDate": "2018-11-04T23:20:00.000Z", "completeDate": "2018-11-04T23:29:59.423Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "442587", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Please share a full reproducible sample project that we can test to verify the issue. Thanks.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2018-10-13T23:27:14.000+0000", "updated": "2018-10-13T23:27:14.000+0000" }, { "id": "442842", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master: https://github.com/appcelerator/titanium_mobile/pull/10391", "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-10-22T20:37:07.000+0000", "updated": "2018-10-22T20:37:07.000+0000" }, { "id": "443310", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix in SDK 7.5.0.v20181101101355.\r\nClosing.\r\n", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-11-05T22:58:35.000+0000", "updated": "2018-11-05T22:58:35.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }