Changing language while the apps is running

You must Login before you can answer or comment on any questions.

Hi, I have two questions to ask: 1- Do you know any apps in iOS where user can change the language ?

2- I have two language for my apps English and French i'm managing it with the L() function and it works well. I want to allow the user to change the apps language, I found a solution for that it works after the resetting the apps. Is there a solution to change language inside the apps (rest the apps..) ?

here is my code:

// app.js
 
(function() {
    if(Ti.App.Properties.getString('lang') == 'undefined')
    {
        if(Titanium.Locale.getCurrentLanguage() == 'fr')
        {
            Ti.App.Properties.setString('lang', 'fr');
        }
        else
        {
            Ti.App.Properties.setString('lang', 'en');
        }
    }   
    else
    {
        Ti.App.Properties.setString('lang', Ti.App.Properties.getString('lang'));
    }
 
    var winLogin = require('ui/winLogin').createWindow();
    winLogin.open();
})();
// language page
// a picker with fr and en to chose a language 
//event on done button
 
done.addEventListener('click',function() {
        Ti.App.Properties.setString('lang', picker.getSelectedRow(0).value);
        pickerView.animate(slideOut);
    });

1 Answer

The L function works by itself based on the phone settings. I don't think honestly that anyone would want to change the app's language while running, but if you still want this, you ill have to reset every single UI that holds text in your app by hand.

It would be a nightmare but it should work.

— answered 9 months ago by Dan Tamas
answer permalink
3 Comments
  • I agree with you Dan, I have just to convince my client ;)

    — commented 9 months ago by Kheiro Tou

  • Well charge him by hour, and explain him it would take you 10h to do this at least, he will give up :D

    — commented 9 months ago by Dan Tamas

  • hi Dan i found a solution :) just by adding this :

    done.addEventListener('click',function() {
            Ti.App.Properties.setString('lang', picker.getSelectedRow(0).value);
            pickerView.animate(slideOut);
            //close the current tabGroup 
            winParam.tabGroup.close();
            //reload the tabGroup
            var application = require('ui/tabs').createTabs();
            application.open();
        });

    — commented 9 months ago by Kheiro Tou

Your Answer

Think you can help? Login to answer this question!