作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正尝试为我的应用程序支持按应用程序语言。我关注了the instructions :
locales_config.xml
:<?xml version="1.0" encoding="utf-8"?>
<locale_config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="en-US"/>
<locale android:name="fr"/>
</locale_config>
我在 AndroidManifest.xml
中添加:
android:localeConfig="@xml/locales_config"
app/build.gradle
中,我添加了:android {
...
defaultConfig {
...
resConfigs "en_US", "fr"
}
}
我的问题是我的应用程序没有出现在每应用程序的语言设置中。
我在模拟器和运行稳定的 Android 13 的手机上对其进行了测试。
附加信息:
com.android.tools.build:gradle:7.2.2
compileSdkVersion 33
如果有人成功了,我想知道是否还缺少其他任何步骤。
编辑:
当用 en
替换 en-US
和 en_US
时,它也不起作用。
最佳答案
locales_config.xml
中的根元素必须是 <locale-config>
,但在你的 xml 中我看到了 <locale_config>
(下划线应该是连字符)。
更新您的 locales_config.xml
到下面的文本,它将起作用:
<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="en-US"/>
<locale android:name="fr"/>
</locale-config>
关于android - 应用程序未出现在每个应用程序的语言设置中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73539311/
我是一名优秀的程序员,十分优秀!