Devrath
Devrath

Reputation: 42834

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

Problem: Once I downloaded app from play-store i can just see English strings in app and Bahasa language is not coming when I switch the language

Question : Does specifying language-split = true causing this

Upvotes: 2

Views: 1359

Answers (2)

Devrath
Devrath

Reputation: 42834

@Jael ... Has a good answer which he shared which I was not aware of so [+1] for the help

But I could resolve this by

language { enableSplit = false }

Upvotes: 0

Jeel Vankhede
Jeel Vankhede

Reputation: 12118

Everything you're doing is okay, it seems that when your device doesn't contains specified language you selected from app (I.e. language settings from App), Play core library fails to fetch that resources for you because your device doesn't support that Locale.

So, the solution is to manually request for it to download that resources for you.

You can do that by making request to SplitsInstallManager.

Create your new SplitsInstallRequest and provide it to SplitsInstallManager so that it would provide that resources for you.

Check out code snippet below:

// 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 about more details.

Upvotes: 2

Related Questions