Android 本地化 es-r419
我正在本地化我的应用程序,支持的语言/区域之一是 Espanol-419。 Android 不支持命名约定values-es-r419,但它接受values-en-rGB。 我应该使用什么名称才能使其正常工作?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我正在本地化我的应用程序,支持的语言/区域之一是 Espanol-419。 Android 不支持命名约定values-es-r419,但它接受values-en-rGB。 我应该使用什么名称才能使其正常工作?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
我不知道r419从何而来。我唯一能想到的是 LCID,但 419 代表俄罗斯,或者 国家代码,但是 419 没有任何内容。以下是西班牙语的区域设置代码列表,也许您想要的代码就在这里:
参考:
更新:
所以显然 419 来自UN M.49 标准由BCP 47 用于 IETF 语言标记。 Google 的有关替代资源的文档表示:
显然(仅通过“r”)您可以看到这些不是标准的 IETF 语言标签。不幸的是,我相信这也意味着您将无法找到相当于 419 的合适的两个字母区域。您还可以检查 官方 ISO 列表。它不在那儿,只有两个国家的字母标签。显然它非常常见 不支持3位数字标签。
我能想到的唯一解决方案是为
es
提供默认集,然后为es
国家/地区的细分提供更具体的集。您可以为您认为与 419 匹配的每个区域(例如es-rAR
)提供资源,但查看该列表,我认为做相反的操作并使用会更容易es
提供拉丁美洲西班牙语的资源,然后为西班牙的es-rES
提供资源。由于es-rES
比es
更具体,因此它应该优先(如果区域设置匹配)。I don't know where r419 comes from. The only thing I could think that it would be is an LCID but 419 is for Russian, or a country code, but there's nothing for 419. Here are a list of locale codes for Spanish, perhaps the one you want is in here:
References:
Update:
So apparently 419 is from the UN M.49 standard taken up by BCP 47 for the IETF language tag. Google's documentation on alternative resources says:
Clearly (by the "r" alone) you can see that these are not standard IETF language tags. Unfortunately, I believe this also means that you won't be able to find a suitable two letter region equivalent to 419. You can also check the official ISO list. It's not on there, there are only two letter tags for countries. Apparently it's very common not to support the 3-digit tags.
The only solution I can think of is to provide a default set for
es
and then a more specific set for a subdivision ofes
countries. You could provide resources for each region (likees-rAR
) that you think matches up with 419, but looking at that list, I think it'd be easier to do the opposite and usees
to provide resources for Latin American Spanish, and then provide resources fores-rES
for Spain. Ases-rES
is more specific thanes
, it should take precedence (if the locale matches).将文件夹名称更改为
values-es-rUS
以与运行时用户选项保持一致。使用 Google 翻译服务时,当您请求将拉丁美洲翻译为西班牙语时,您将收到返回的
es-r419
文件夹。当查看 AOSP 源代码时,或者在
设置->语言和输入->语言
中,您将看到西班牙语和西班牙语(美国)。在运行时,选择语言 = 西班牙语(美国),您将不会看到从
values-es-r419
中提取的字符串,当然您会看到从values-es-rUS< 中提取的字符串/代码>
change the folder name to
values-es-rUS
for consistency with runtime user options.When using Google Translation services, when you request translation to Spanish for Latin America, you will receive
es-r419
folder returned.When looking at AOSP source, or in the
settings->language and input->language
, you will see Spanish and Spanish (United States).At runtime, selecting language = Spanish (United States), you will not see strings pulled from
values-es-r419
, and of course you will see strings pulled fromvalues-es-rUS
来源:https://developer.android.com/guide/topics/ resources/multilingual-support.html
我们在应用内提供了语言选择,因此为了在新旧手机上都能正常工作,我们在
values-es-rUS
Español (Estados) 中保留了重复的资源Unidos) 以及values-b+es+419
Español (Latinoamérica)Source: https://developer.android.com/guide/topics/resources/multilingual-support.html
We offered language selection in-app, so to work well on new and old phones we kept duplicate resources in
values-es-rUS
Español (Estados Unidos) as well asvalues-b+es+419
Español (Latinoamérica)419 来自此处,适用于任何拉丁美洲(西班牙语)地区。
我们也可以使用 这个代表每个地区而不是名字,虽然比较困难
但是,如果我们想要每个区域都有一种语言,则文件中必须包含语言,后跟“-r”和国家/地区代码。选择区域时会自动添加名称。
为此,请创建一个“值资源文件”,选择“区域设置”选项并选择区域。
如果设备语言是“英语(美国)”,则将采用values-en-rUS/strings.xml。
如果设备的语言是我们不支持的国家/地区,则将使用values-en/strings.xml(任何地区都使用)。
现在,如果您想以编程方式添加语言,则无法将语言设置为“en_US”或“en-rUS”,因为它不存在,“en_US”仍然是“en”。
这就是为什么你需要将国家添加到区域设置语言中(android支持大写或小写)
419 comes from here, and is for any LatinoAmérica (Spanish) regions.
We can also use this for each region instead of names, although it is more difficult
But, if we want a language for each region, the file must have the language followed by "-r" and the country code. The name is added automatically when choosing the region.
To do that, create a "value resource file", choose the "Locale" option and choose the region.
If the device language is "English (United States)" will take values-en-rUS/strings.xml.
If the device has a language with a country that we do not support, will use values-en/strings.xml (is used by any region).
Now, if you want to programmatically add the language, you cannot set the language as "en_US" or "en-rUS" because it doesn't exists, "en_US" is still "en".
That's why you need to add the country to the Locale language (android supports upper or lower case)