[AC-5887] Solution for Ti.Locale.setLanguage change not working in oreo 8.0
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Resolved |
| Resolution | Cannot Reproduce |
| Resolution Date | 2019-01-08T16:07:54.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | n/a |
| Reporter | Pietro Granati |
| Assignee | Shak Hossain |
| Created | 2018-09-14T15:52:21.000+0000 |
| Updated | 2019-01-14T08:45:08.000+0000 |
Description
Hello I've an app that can change language on tuntime, it works fine on my tablet (Android 6) but not on my smartphone that is Android 8, I found this article:
https://www.reddit.com/r/androiddev/comments/8b2rol/solution_for_locale_language_change_not_working/
And it seems to be an issue of android 8, what can we do?
Attachments
| File | Date | Size |
|---|---|---|
| thumbnail.jpeg | 2018-12-12T05:55:21.000+0000 | 11104 |
| thumbnail (1).jpeg | 2018-12-12T05:54:52.000+0000 | 9462 |
Hello, If this is a native Android issue, Then Android has to provide a fix on its update. There is not much we can do here I believe. We will keep it open for other developer having the same issue. Thanks.
Doesn't seem to work correctly on Android 8.0.0, setting the textid directly does work. When you get a string with L('key') it doesn't work, what is strange is that it does seem to work when you run the app with liveview enabled. Is there something wrong with the L function? Test on: Samung s9 (Android 8.0.0) and emulator (Android 8.0.0, 6.0.0). SDK: 7.5.0.GA Example (does need to have the strings.xml file):
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var container = Ti.UI.createView({ height: Ti.UI.SIZE, layout: 'vertical' }); var label1 = Ti.UI.createLabel({ text: 'Current Locale: ' + Ti.Locale.currentLanguage + ' (' + L('hello_world') + ')', color: 'black' }); var label2 = Ti.UI.createLabel({ textid: 'hello_world', color: 'black' }); var btn = Ti.UI.createButton({ title: 'Change' }); btn.addEventListener('click', function () { var newLang = Ti.Locale.currentLanguage == 'de' ? 'en' : 'de'; Ti.Locale.setLanguage(newLang); label1.text = 'Current Locale: ' + Ti.Locale.currentLanguage + ' (' + L('hello_world') + ')'; label2.textid = 'hello_world'; }); container.add(btn); container.add(label1); container.add(label2); win.add(container); win.open();Hello [~Pietro], I just wanted to follow up with you about this issue? Are you still experiencing this problem? Please let us know if you need more help with this issue. Thanks
I still have this problem on Android 8.0 and higher. It seems like it's just the L function (or Ti.Locale.getString) that is affected, setting textid on a label does seem to work (see sample above).
Hello, Tested the issue on android 8 device and it seems worked for me. See the attachment section for output. You can also test again from [here ](https://gist.github.com/rakhimonimitro/e0532a843926e1d996e964d87fd0d4ee) and let us know how it goes. Thanks
I've tested it with the sample you provided and it still doesn't work for me with liveview disabled, when I launch the app with liveview enabled it does work. When I disable liveview only the second label changes it's text. I've tested it on a Samsung S9 with Oreo an a simulator with Oreo.
Hello [~teunklijn@telfort.nl], As rakhi posted before the issue works fine with Android 8.0. I tested the issue myself and got the same result. I was able to duplicate the behavior as rakhi. I got the same as the screenshots attached above. Tested with SDK 7.5.0.GA.