如何更新应用程序的用户选择了一个语言? [英] How to update the language of application by user selected one?

查看:137
本文介绍了如何更新应用程序的用户选择了一个语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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/

这篇关于如何更新应用程序的用户选择了一个语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆