各种语言的Andr​​oid的strings.xml,情景 [英] android strings.xml in various languages, scenario

查看:192
本文介绍了各种语言的Andr​​oid的strings.xml,情景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题的strings.xml

I have a strings.xml question

我的应用程序是英文的。

My app is in english.

价值/ strings.xml中是英文

有许多其他语言的应用程序太

there are many other languages in the app too

我最新的字符串键添加在值恩/ strings.xml中,在英语语言环境中的文件夹,而不是在默认的语言文件夹

my latest string key additions are in values-en/strings.xml , the english locale folder , but not in values the default language folder

这将如何影响加载它试图访问仅在中定义的字符串景色的非英语用户的值恩?将操作系统找到一个文件中的字符串,并以英文显示呢?

how will this affect a non-english user that loads a view which tries to access the strings only defined in values-en? will the OS find the string in that one file and display it in english?

这是棘手的我,因为它不是在默认值xml文件

this is tricky to me because it is not in the default values xml file

感谢您的见解。

推荐答案

想象一下琴弦系统作为一系列if条件。首先,我们检查用户的语言,一旦我们有我们检查,看看是否该特定语言的文件夹包含了我们正在寻找的字符串。如果确实如此,我们返回该字符串,否则我们默认勾选值文件夹中。

Imagine the strings system as a series of if conditions. First we check the language of the user, once we have that we check to see if the folder for that specific language contains the string we are looking for. If it does, we return that string, otherwise we check the "values" folder by default.

if (language.equals("en") {
   stringsFolders = "values-en";
} else if (language.equals("es") {
   stringsFolders = "values-es";
} 

if (stringsFolder.contains(key) {
    return stringsFolder.get(key);
} else if ("values".contains(key) {
    return "values".get(key);
} else {
    throw CantFindException();
}

如果一个字符串值,属于恩和西班牙用户查找它,他们不会有机会检查值-en文件夹,因为他们没有资格获得它。另外,价值观文件夹默认将总是选中所以把它放在那里将为所有语言

If a string belongs in values-en and a spanish user looks for it, they will not have the opportunity to check the values-en folder because they don't qualify for it. Alternatively, the "values" folder is always checked by default so placing it there will work for all languages

这篇关于各种语言的Andr​​oid的strings.xml,情景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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