应用程序中未显示多语言字符串

Multilingual strings are not displaying in app


android {
    // When building Android App Bundles, the splits block is ignored.
    splits {...}

    // Instead, use the bundle block to control which types of configuration APKs
    // you want your app bundle to support.
    bundle {
        language {
            // Specifies that the app bundle should not support
            // configuration APKs for language resources. These
            // resources are instead packaged with each base and
            // dynamic feature APK.
            enableSplit = true
        }
        density {
            // This property is set to true by default.
            enableSplit = true
        }
        abi {
            // This property is set to true by default.
            enableSplit = true
        }
    }
}

问题:从 Play 商店下载应用程序后,我只能在应用程序中看到 English 字符串,并且当我切换时 Bahasa 语言不会出现语言

问题:是否指定 language-split = true 导致此

你所做的一切都很好,当你的设备不包含你从应用程序中选择的指定语言时似乎(即来自应用程序的语言设置)Play 核心库 无法为您获取该资源,因为您的设备不支持该区域设置。

因此,解决方案是手动请求它为您下载该资源。

您可以通过向 SplitsInstallManager 提出请求来做到这一点。

创建您的新 SplitsInstallRequest 并将其提供给 SplitsInstallManager,以便它为您提供该资源。

查看下面的代码片段:

// Creates a request to download and install additional language resources.
val request = SplitInstallRequest.newBuilder()
    // Uses the addLanguage() method to include French language resources in the request.
    // Note that country codes are ignored. That is, if your app
    // includes resources for “fr-FR” and “fr-CA”, resources for both
    // country codes are downloaded when requesting resources for "fr".
    .addLanguage(Locale.forLanguageTag("your language code here"))
    .build()

// Submits the request to install the additional language resources.
splitInstallManager.startInstall(request)

Refer here了解更多详情。

@Jael ...他分享了一个我不知道的很好的答案,所以[+1]寻求帮助

但我可以通过

解决这个问题
language { enableSplit = false }