Live Playstore 应用程序不翻译我的文本

Live playstore app not translating my texts

我用 2 个字符串文件创建了一个应用程序。 1. strings.xml 内部值 2. strings.xml inside values-kn

我的用户选择卡纳达语时翻译的代码如下:

Locale locale = new Locale(language);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext()
            .getResources()
            .updateConfiguration(config, getBaseContext()
                    .getResources()
                    .getDisplayMetrics());

当我在不同的 android 手机上制作调试版本或发布版本并 运行 它时,此代码工作正常。 但是当我将应用程序包上传到 Play 商店时,它不会更新我在该版本中的语言。我还在 Play 商店中为 kn-in 添加了翻译,但我仍然无法将我在应用程序中的文本翻译成卡纳达语。

有人可以解释一下我在这里做错了什么还是我错过了什么?这个问题一直困扰着我。

基本上我构建的问题是,我正在尝试新的发布包功能并将其上传到 Play 商店。

因此,如果您在发布时使用最新的 App Bundle 工具,那么它会在安装时根据用户的 phone 设置删除本地化文件。

我得到了这个非常有用的 tutorial 它教你如何即时更改应用程序的语言,并且在它的评论部分中找到了我的问题的答案。

要解决我的问题,我所要做的就是:

将此放在应用程序文件夹内 build.gradle 文件中的 android 标签内。

android {
//...
//... removed for brevity
     bundle {
        language {
           enableSplit = false
        }
    }
}

希望它能帮助可能 运行 解决此问题的人。干杯!

基于 Google I/O 2018 Google Play 将负责即时下载所选语言。

In the rare case, where a user switches to a new language that we weren't aware of before, Play will dynamically deliver relevant splits to their device. (https://youtu.be/0raqVydJmNE?t=13m9s)

根据接受的答案,我们可以将其设置为false,但在实际场景中不需要。用户很少可以更改语言,应用程序包帮助我们通过拆分资源来最小化应用程序大小。