Reputation: 163
I'm currently trying to support per-app languages for my app. I followed the instructions:
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"
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
.
Upvotes: 6
Views: 2524
Reputation: 688
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>
Upvotes: 3
Reputation: 879
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.)
Upvotes: 1
Reputation: 76639
The default locale is always: <locale android:name="en"/>
and not en-US
or en-GB
.
Upvotes: 0