在 android 个 app bundle 上处理应用内的动态语言更改
Handle dynamic language change within the app on android app bundle
我使用了最新的 android 打包格式捆绑包并将我的应用程序发送到测试版渠道,捆绑包减少了约 60% 的应用程序大小,这真是太棒了,
我的应用支持英语和阿拉伯语(可以在应用内即时切换)
现在的问题是:据我所知,基本 apk 在应用程序下载期间将只有用户语言的资源(如果在下载时,如果语言是 english.only 字符串-en.xml 会被下载)
那么我该如何处理用户在应用程序中切换语言的情况..
请告诉我..
据我所知,您可以使用 bundle 块来控制您希望应用程序包支持哪些类型的配置 APK。
android {
...
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 = false
}
}
}
目前我只发现,通过在系统设置中更改设备语言,您的应用程序会自动从 Play 商店下载其他语言的 APK,前提是您已将该语言的资源包含在您的应用程序包中。仍在尝试查找是否可以通过我的应用程序中的 PlayCore 库手动提交对其他语言的请求...
Play核心库1.4.0版本,您可以请求Play商店按需安装新语言配置的资源,并立即开始使用。
// Creates a request to download and install additional language resources.
SplitInstallRequest 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("fr"))
.build();
// Submits the request to install the additional language resources.
splitInstallManager.startInstall(request);
更多信息:
https://developer.android.com/guide/app-bundle/playcore#lang_resources
我使用了最新的 android 打包格式捆绑包并将我的应用程序发送到测试版渠道,捆绑包减少了约 60% 的应用程序大小,这真是太棒了,
我的应用支持英语和阿拉伯语(可以在应用内即时切换)
现在的问题是:据我所知,基本 apk 在应用程序下载期间将只有用户语言的资源(如果在下载时,如果语言是 english.only 字符串-en.xml 会被下载)
那么我该如何处理用户在应用程序中切换语言的情况..
请告诉我..
据我所知,您可以使用 bundle 块来控制您希望应用程序包支持哪些类型的配置 APK。
android {
...
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 = false
}
}
}
目前我只发现,通过在系统设置中更改设备语言,您的应用程序会自动从 Play 商店下载其他语言的 APK,前提是您已将该语言的资源包含在您的应用程序包中。仍在尝试查找是否可以通过我的应用程序中的 PlayCore 库手动提交对其他语言的请求...
Play核心库1.4.0版本,您可以请求Play商店按需安装新语言配置的资源,并立即开始使用。
// Creates a request to download and install additional language resources.
SplitInstallRequest 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("fr"))
.build();
// Submits the request to install the additional language resources.
splitInstallManager.startInstall(request);
更多信息: https://developer.android.com/guide/app-bundle/playcore#lang_resources