- 我在 gradle 中有这个设置
- 我已上传
.aab
playstore。 - 该应用支持多种语言,即
英语
和马来语
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核心库 strong> 无法为您获取该资源,因为您的设备不支持该区域设置。
因此,解决方案是手动请求它为您下载该资源。
您可以通过向 SplitsInstallManager
发出请求来做到这一点。
创建新的 SplitsInstallRequest
并将其提供给 SplitsInstallManager
,以便它为您提供该资源。
查看下面的代码 fragment :
// 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 了解更多详细信息。
关于android - 应用程序中不显示多语言字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57781961/