如何塞尔维亚包括语言2种型号?用拉丁字母和西里尔字母 [英] How to include 2 variants of Serbian Language? with Latin letters and with Cyrillic letters

查看:1644
本文介绍了如何塞尔维亚包括语言2种型号?用拉丁字母和西里尔字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序,我想转换为塞尔维亚人,我想语言的这两种型号:用拉丁字母和西里尔字母。
我想这个变种:价值-SR-RRS-LATN,价值SR-LATN,价值SR-RRS-Cyrl,价值SR-Cyrl
但不是正在工作。
我得到这个错误: Android的易编译:[NAMEOFAPP]无效的资源目录名:[路径] \\ RES /值-SR-RRS-LATN

I have an android app and I want to translate to Serbian and I want both variants of the language: with Latin letters and with Cyrillic letters. I tried this variants: value-sr-rRS-Latn , value-sr-Latn , value-sr-rRS-Cyrl , value-sr-Cyrl but not of that is working. I get this error: android-apt-compiler: [NAMEOFAPP] invalid resource directory name: [path]\res/value-sr-rRS-Latn

在有关资源显示目录和Locale我无法找到这个选项Android文档。

On Android documentation about res dirs and Locale I can't find this option.

我可以做2迪尔斯的语言的2种型号?怎么样?

Can I make 2 dirs with 2 variants of the language? And how?

感谢您

推荐答案

我只是测试Android的本地化和我发现,你可以使用任意的区域,也将努力。

I just tested Android localization and I found out that you can use any arbitrary region and it will work.

一个文件夹名称添加到项目中如值-SR-RZZ 其中ZZ是从来不存在一个虚构的区域。

Add a folder to the project with name like values-sr-rZZ where ZZ is a fictitious region which never existed.

那么下面code添加到应用程序类,我是从<一个href=\"http://stackoverflow.com/questions/2900023/change-language-programatically-in-android\">here而略有变化:

Then add the following code to the Application class, I got it from here and slightly changed:

public class MainApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        Resources res = this.getResources();
        Configuration conf = res.getConfiguration();
        boolean isLatinAlphabet = PreferenceManager.getDefaultSharedPreferences(this)... // get a value from the application settings

        if(conf.locale.getLanguage().equals("sr") && isLatinAlphabet) {
            conf.locale = new Locale("sr", "ZZ");
            res.updateConfiguration(conf, res.getDisplayMetrics());
        }
    }
}

在此code语言环境,如果用户选择了塞尔维亚语作为默认只会改变( conf.locale.getLanguage()。等于(SR)),也查了一些复选框中的应用preferences( isLatinAlphabet )。

In this code the locale will be changed only if the user has chosen the serbian language as the default (conf.locale.getLanguage().equals("sr")) and also checked some checkbox in the app preferences (isLatinAlphabet).

您可以使用不同的条件,并改变它,只要你喜欢。

You can use a different condition and change it as you like.

也改变语言可以有旧设备上的菜单项的bug这种动态的方式,但它不复制在较新的设备。

Also such dynamic way of changing language can have bugs with menu items on older devices, but it isn't reproduced on newer devices.

这篇关于如何塞尔维亚包括语言2种型号?用拉丁字母和西里尔字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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