如何仅使用本地化文件夹中的字符串资源文件?

时间:2017-06-30 13:07:02

标签: android android-resources

有俄语应用程序不会本地化,但俄语中的复数与英语不同,所以如果系统语言是俄语 - 一切都可以,但如果系统语言不是俄语(例如英语) - 那么那里出现问题......当系统语言不是俄语时,如何仅使用文件夹“values-ru”中的资源?

1 个答案:

答案 0 :(得分:0)

String localLanguage = Locale.getDefault().getLanguage();

        if (localLanguage.equals("eng")){
            Locale locale = new Locale("eng");
            Locale.setDefault(locale);
            Configuration config = getBaseContext().getResources().getConfiguration();
            config.locale = locale;
            getBaseContext().getResources().updateConfiguration(config,
                    getBaseContext().getResources().getDisplayMetrics());
        }else {
            Locale locale = new Locale("ru");
            Locale.setDefault(locale);
            Configuration config = getBaseContext().getResources().getConfiguration();
            config.locale = locale;
            getBaseContext().getResources().updateConfiguration(config,
                    getBaseContext().getResources().getDisplayMetrics());
        }

根据默认语言更改应用语言..!

我希望它对你有用......!

相关问题