Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Live playstore app not translating my texts

I made an application with 2 string files. 1. strings.xml inside values 2. strings.xml inside values-kn

The code to translate when my user selects kannada is as follows:

Locale locale = new Locale(language);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext()
            .getResources()
            .updateConfiguration(config, getBaseContext()
                    .getResources()
                    .getDisplayMetrics());

This code works fine when I make a debug build or a release build and run it on different android phones. But when I upload the app bundle to the play store it does not update my language in that build. I also added a translation in the play store for kn-in but still I am not being able to translate my texts in the app to kannada.

Can somebody please explain what I am doing wrong here or am I missing out on something? This problem has been eating my brains out.

like image 204
theAndDev Avatar asked Jan 14 '19 13:01

theAndDev


Video Answer


1 Answers

Basically the problem with my build was, I was trying out the new release bundle feature and uploading it to the play store.

So If you are using the latest App Bundle tool when you're publishing then it removes localization files based on the user's phone settings when it's been installing.

I got this extremely useful tutorial which teaches you how to change the apps language on the fly and also on the comments section of it the answer to my problem lied.

To solve my problem all I had to do was:

Put this inside android tag in build.gradle file inside the app folder.

android {
//...
//... removed for brevity
     bundle {
        language {
           enableSplit = false
        }
    }
}

Hope it helps some one out there who might run into this problem. Cheers!

like image 156
theAndDev Avatar answered Sep 28 '22 22:09

theAndDev