App does not appear in Per-app language settings
Asked Answered
G

3

6

I'm currently trying to support per-app languages for my app. I followed the instructions:

  • I created locales_config.xml:
<?xml version="1.0" encoding="utf-8"?>
<locale_config xmlns:android="http://schemas.android.com/apk/res/android">
    <locale android:name="en-US"/>
    <locale android:name="fr"/>
</locale_config> 

which I added in AndroidManifest.xml:

android:localeConfig="@xml/locales_config"
  • In app/build.gradle, I added:
android {
    ...
    defaultConfig {
        ...
        resConfigs "en_US", "fr"
    }
}

My problem is that my app does not appear in Per-app language settings.
I tested it on both an emulator and a phone running stable Android 13.

Additional info:

com.android.tools.build:gradle:7.2.2
compileSdkVersion 33

If anyone got this working, I'd like to know if there's any other additional step I'm missing.

Edit:
It doesn't work either when replacing both en-US and en_US with en.

Goldagoldarina answered 30/8, 2022 at 8:26 Comment(0)
B
3

The root element in locales_config.xml must be <locale-config>, but in your xml I see <locale_config> (underscore should be a hypen).

Update your locales_config.xml to the text below, and it will work:

<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
    <locale android:name="en-US"/>
    <locale android:name="fr"/>
</locale-config>
Berkin answered 16/10, 2022 at 5:46 Comment(0)
T
0

The default locale is always: <locale android:name="en"/> and not en-US or en-GB.

Traitor answered 3/9, 2022 at 9:9 Comment(1)
It may be part of the problem, but I still don't see my app in settings.Goldagoldarina
Y
0

I was dealing with the same issue and it turns out my issue was that I didn't put the android:localeConfig="@xml/locale_config" in the right place in the manifest.

It's supposed to be associated with the application tag:

<application android:localeConfig="@xml/locale_config" android:icon="@mipmap/ic_launcher" ...

(Also, check that the name you specify there matches your XML filename. @xml/locale_config implies a "locale_config.xml" file saved in the xml resource folder.)

Yeung answered 9/10, 2022 at 23:15 Comment(2)
Thanks for your answer. However, my app was already set up like that. I tried renaming locales_config.xml to locale_config.xml, without any result.Goldagoldarina
@Tim241 Could you post your AndroidManifest.xml and locales_config.xml files in full, as well as where they appear in your directory structure? The problem might be as simple as a typo.Yeung

© 2022 - 2024 — McMap. All rights reserved.