Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5887] Solution for Ti.Locale.setLanguage change not working in oreo 8.0

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2019-01-08T16:07:54.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterPietro Granati
AssigneeShak Hossain
Created2018-09-14T15:52:21.000+0000
Updated2019-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

FileDateSize
thumbnail.jpeg2018-12-12T05:55:21.000+000011104
thumbnail (1).jpeg2018-12-12T05:54:52.000+00009462

Comments

  1. Sharif AbuDarda 2018-09-15

    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.
  2. Ahmed Mohamed 2018-09-16

  3. Teun Klijn 2018-11-28

    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();
       
  4. Rakhi Mitro 2018-12-10

    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
  5. Teun Klijn 2018-12-11

    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).
  6. Rakhi Mitro 2018-12-12

    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
  7. Teun Klijn 2018-12-12

    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.
  8. Sharif AbuDarda 2019-01-04

    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.
  9. Teun Klijn 2019-01-14

JSON Source