gpt4 book ai didi

当设备语言为 en_US 时,Android 7.0 Nougat 会选择默认字符串

转载 作者:太空宇宙 更新时间:2023-11-03 10:37:35 25 4
gpt4 key购买 nike

根据 Language and Locale 中的文档从 Android 7.0(API 级别 24)开始,对资源解析策略进行了改进,下表很容易理解: Improved Resource-Resolution strategy

根据我的要求,我希望我的应用程序的默认语言为 en_US。因此,我没有为 en_US 提供单独的资源。我也有单独的 en_GB 资源。

现在,根据解析策略,如果我的设备的语言是 en_US,那么它查找资源的顺序应该是 en_US -> en -> en_GB -> default 这意味着所有 en 语言环境,在我的例子中是 en_GB将被拾取,因为我没有单独的“en”资源,但子“en_GB”存在。

但是,当我选择我的设备语言为 en_US 时,它会正确选择默认语言(在我的例子中为 en_US)而不是 en_GB,这正是我在设备语言为 en_US 时所需要的。选择 en_IN 或 en_AU 等其他语言环境时,它会选择 en_GB。

解决此问题的一种方法是我在“en”和 en_GB 中分别提供 en_US 字符串,这将导致我想要的行为。但是,当我选择 en_US 作为我的设备语言时,我无法理解为什么会选择默认字符串。

是不是 en_US 是 android 的默认语言,只要选择 en_US 作为设备的语言,如果没有单独提供 en_US,它就会选择默认字符串?

最佳答案

我遇到了同样的问题。在 Google 上打开错误报告后 Incorrect resource resolution strategy above Android N, defaulting to en_GB and not default strings.xml ,他们在上面的 Android N 的预期行为中提到了这一点。我在这里引用他们的回复:

Starting in N, all English locales (except for US and US territories like Puerto Rico and American Samoa) fall back to some International English variant if such a locale is available.

So for en-CA, we would try these locales first, before falling back on en-GB (which is considered a representative of International English if there is no better International English locale): en-rCA (Canadian English), b+en+001 (International English), en (English).If you don't want en-GB strings to be picked up for en-CA, you should put resources in one of those three directories, as they would be considered a better match for en-CA.

于是,我们的en_UK就被认为是“国际英语的代表”。字符串将回退到 en 之前的“International English”或其代表。

关于当设备语言为 en_US 时,Android 7.0 Nougat 会选择默认字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40906548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com