如何更新应用程序的用户选择了一个语言?应用程序、选择了、语言、用户

由网友(小洋人。)分享简介:在我的项目存在用于用户选择的语言的选择。整个应用程序应该通过选择语言改变。语言是从服务器端获取。 In my project there is a option for the user to select language. The whole application should change by select...

在我的项目存在用于用户选择的语言的选择。整个应用程序应该通过选择语言改变。语言是从服务器端获取。

In my project there is a option for the user to select language. The whole application should change by selecting the language. Language is fetched from the server side.

我提到的各种网站和链接,但无法找到一个更好的解决方案。定位是不可能的,因为这是一个巨大的应用并也语言不是固定的,它是从服务器端取出,它可以改变。

I referred various sites and links, but couldn't find a better solution. Localization is not possible, because it's a huge app and also language is not fixed , it is fetched from the server side and it can be varied.

时的任何其他解决方案可用?请帮助...

Is any other solution is available? Please help...

推荐答案

虽然它不推荐使用单独的语言比Android系统的其他您的应用程序。但你仍然可以改变它。

Although its not recommended to use separate language for your app other than the Android system's . But you can still change it .

下面是code:

private void setLocale (String localeCode , Bundle b ){
    Log.d(TAG+"set location function: "+localeCode);
    locale = new Locale(localeCode);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    getApplicationContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    UserDetail.this.getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
    onCreate(null);
}

这是一些用户触发使用此方法调用:

Use this method call on some user trigger:

setLocale("en-us",savedInstanceStat); // for english
setLocale("ar",savedInstanceStat); // for arabic

要了解更多关于Android的当地人:的http://www.icanlocalize.com/site/tutorials/android-application-localization-tutorial/

To learn more about android locals: http://www.icanlocalize.com/site/tutorials/android-application-localization-tutorial/

阅读全文

相关推荐

最新文章