Megaetron
Megaetron

Reputation: 1202

App name doesn't change language after user changes it programmatically

I give my user the opportunity to change the app language. I use this:

public void languageToLoad(String language) {
    String lang = language;
    Locale locale = new Locale(lang);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
            getBaseContext().getResources().getDisplayMetrics());
}

for english: languageToLoad(en) or french: languageToLoad(fr)

But my problem is that the app name won't change.

strings.xml (en):

<string name="app_name">SoccerPro</string>

strings.xml (fr):

<string name="app_name">FootballPro</string>

Every string changes its value but not 'app_name'.

If the device language gets changed then it changes but not like my way. What am I doing wrong?

Upvotes: 0

Views: 626

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007554

Your call to updateConfiguration() affects your process at most. It does not affect other processes. Which means that unless your app is the home screen, the home screen will not change. updateConfiguration() does not affect the user's language at a system level, and AFAIK there is no way for an ordinary SDK app to do that.

Upvotes: 2

Related Questions