Android 本地化 es-r419

发布于 2024-12-28 00:35:37 字数 113 浏览 3 评论 0 原文

我正在本地化我的应用程序,支持的语言/区域之一是 Espanol-419。 Android 不支持命名约定values-es-r419,但它接受values-en-rGB。 我应该使用什么名称才能使其正常工作?

I'm localizing my app and one of the language/region supported is Espanol-419. Android doesn't support the naming convention values-es-r419 but it does accept values-en-rGB.
What name should I use to make it work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

醉南桥 2025-01-04 00:35:37

我不知道r419从何而来。我唯一能想到的是 LCID,但 419 代表俄罗斯,或者 国家代码,但是 419 没有任何内容。以下是西班牙语的区域设置代码列表,也许您想要的代码就在这里:

es-ar  Spanish - Argentina
es-bo  Spanish - Bolivia    
es-cl  Spanish - Chile
es-co  Spanish - Colombia
es-cr  Spanish - Costa Rica
es-cu  Spanish - Cuba
es-do  Spanish - Dominican Republic
es-ec  Spanish - Ecuador
es-sv  Spanish - El Salvador
es-gt  Spanish - Guatemala
es-hn  Spanish - Honduras
es-mx  Spanish - Mexico
es-ni  Spanish - Nicaragua
es-pa  Spanish - Panama
es-py  Spanish - Paraguay
es-pe  Spanish - Peru
es-pr  Spanish - Puerto Rico
es-es  Spanish - Spain (Traditional)
es-uy  Spanish - Uruguay
es-ve  Spanish - Venezuela

参考:

更新:

所以显然 419 来自UN M.49 标准BCP 47 用于 IETF 语言标记。 Google 的有关替代资源的文档表示

语言由两个字母的 ISO 639-1 语言代码定义,后面可以选择两个字母的 ISO 3166-1-alpha-2 区域代码(前面带有小写“r”)。

显然(仅通过“r”)您可以看到这些不是标准的 IETF 语言标签。不幸的是,我相信这也意味着您将无法找到相当于 419 的合适的两个字母区域。您还可以检查 官方 ISO 列表。它不在那儿,只有两个国家的字母标签。显然它非常常见 不支持3位数字标签。

我能想到的唯一解决方案是为 es 提供默认集,然后为 es 国家/地区的细分提供更具体的集。您可以为您认为与 419 匹配的每个区域(例如 es-rAR)提供资源,但查看该列表,我认为做相反的操作并使用 会更容易es 提供拉丁美洲西班牙语的资源,然后为西班牙的 es-rES 提供资源。由于 es-rESes 更具体,因此它应该优先(如果区域设置匹配)。

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:

es-ar  Spanish - Argentina
es-bo  Spanish - Bolivia    
es-cl  Spanish - Chile
es-co  Spanish - Colombia
es-cr  Spanish - Costa Rica
es-cu  Spanish - Cuba
es-do  Spanish - Dominican Republic
es-ec  Spanish - Ecuador
es-sv  Spanish - El Salvador
es-gt  Spanish - Guatemala
es-hn  Spanish - Honduras
es-mx  Spanish - Mexico
es-ni  Spanish - Nicaragua
es-pa  Spanish - Panama
es-py  Spanish - Paraguay
es-pe  Spanish - Peru
es-pr  Spanish - Puerto Rico
es-es  Spanish - Spain (Traditional)
es-uy  Spanish - Uruguay
es-ve  Spanish - Venezuela

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:

The language is defined by a two-letter ISO 639-1 language code, optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r").

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 of es countries. You could provide resources for each region (like es-rAR) that you think matches up with 419, but looking at that list, I think it'd be easier to do the opposite and use es to provide resources for Latin American Spanish, and then provide resources for es-rES for Spain. As es-rES is more specific than es, it should take precedence (if the locale matches).

王权女流氓 2025-01-04 00:35:37
es-r419 = es-rUS. 

将文件夹名称更改为 values-es-rUS 以与运行时用户选项保持一致。

使用 Google 翻译服务时,当您请求将拉丁美洲翻译为西班牙语时,您将收到返回的 es-r419 文件夹。

当查看 AOSP 源代码时,或者在设置->语言和输入->语言中,您将看到西班牙语和西班牙语(美国)。

在运行时,选择语言 = 西班牙语(美国),您将不会看到从 values-es-r419 中提取的字符串,当然您会看到从 values-es-rUS< 中提取的字符串/代码>

es-r419 = 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 from values-es-rUS

幽梦紫曦~ 2025-01-04 00:35:37

Android 7.0(API 级别 24)带来了更强大的资源解析,并自动找到更好的回退。但是,为了加快解决速度并提高可维护性,您应该以最常见的父方言存储资源。例如,如果您之前将西班牙语资源存储在 values-es-rUS 目录中,请将它们移动到 values-b+es+419 目录中,其中包含拉丁美洲西班牙语。

来源: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)

Android 7.0 (API level 24) brings more robust resource resolution, and finds better fallbacks automatically. However, to speed up resolution and improve maintainability, you should store resources in the most common parent dialect. For example, if you were storing Spanish resources in the values-es-rUS directory before, move them into the values-b+es+419 directory, which contains Latin American Spanish.

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 as values-b+es+419 Español (Latinoamérica)

世界等同你 2025-01-04 00:35:37

419 来自此处,适用于任何拉丁美洲(西班牙语)地区。

Español(哥伦比亚)、Español(墨西哥)等将使用values-es-r419

我们也可以使用 这个代表每个地区而不是名字,虽然比较困难

values-en-r840 而不是 value-en-rUS

但是,如果我们想要每个区域都有一种语言,则文件中必须包含语言,后跟“-r”和国家/地区代码。选择区域时会自动添加名称。

为此,请创建一个“值资源文件”,选择“区域设置”选项并选择区域。

输入图片此处描述

如果设备语言是“英语(美国)”,则将采用values-en-rUS/strings.xml。

如果设备的语言是我们不支持的国家/地区,则将使用values-en/strings.xml(任何地区都使用)。

现在,如果您想以编程方式添加语言,则无法将语言设置为“en_US”或“en-rUS”,因为它不存在,“en_US”仍然是“en”。
这就是为什么你需要将国家添加到区域设置语言中(android支持大写或小写)

//Example language = "en" country = "US"
private void setLanguage(Context context, String language, String country) {
    Configuration config = new Configuration(context.getResources().getConfiguration());
    config.setLocale(new Locale(language, country));

    //Copies the fields from delta into this Configuration object, keeping track of which ones have changed.
    config.updateFrom(new Resources(context.getResources().getAssets(),
            context.getResources().getDisplayMetrics(), config).getConfiguration());

    context.createConfigurationContext(config);
}

419 comes from here, and is for any LatinoAmérica (Spanish) regions.

Español (Colombia), Español (México), etc, will use values-es-r419

We can also use this for each region instead of names, although it is more difficult

values-en-r840 intead of values-en-rUS

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.

enter image description here

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)

//Example language = "en" country = "US"
private void setLanguage(Context context, String language, String country) {
    Configuration config = new Configuration(context.getResources().getConfiguration());
    config.setLocale(new Locale(language, country));

    //Copies the fields from delta into this Configuration object, keeping track of which ones have changed.
    config.updateFrom(new Resources(context.getResources().getAssets(),
            context.getResources().getDisplayMetrics(), config).getConfiguration());

    context.createConfigurationContext(config);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文