处理Android应用程序包上的应用程序内的动态语言更改

问题描述 投票:5回答:3

我使用了最新的android打包格式包并将我的应用程序发送到测试版频道,捆绑减少了约60%的应用程序大小真的很棒,

我的应用程序支持英语和阿拉伯语(可以在应用程序中切换)

现在的问题是:AFAIK the base apk在应用程序下载期间只有用户语言的资源(如果在下载时,如果语言是english.only string-en.xml被下载)

那我该如何处理用户在应用程序中切换语言的情况呢

请告诉我..

android localization apk
3个回答
7
投票

AFAIK,您可以使用捆绑块来控制您希望应用程序包支持哪些类型的配置APK。

基于documentation

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
        }
    }
}

3
投票

目前我只发现通过更改系统设置中的设备语言,您的应用会自动从Play商店下载其他语言APK,因为您已在应用包中包含该语言的资源。仍然试图找到我是否可以通过我的应用程序内的PlayCore库手动提交其他语言的请求...


0
投票

使用Play Core库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

© www.soinside.com 2019 - 2024. All rights reserved.