Can't choose language on Android App languages

What platform are you building for?

Android

What framework are you building with?

Cordova

What is your build ID?

1975cfa9-40e0-438c-997e-3ebbf7a96917

What is your error message?

Hi:

I get my Cordova app to show up on the Android App language selection list, though only with the default language, no language selection.

I have a locales_config.xml file in resources/xml with this type of text

<locale-config>
  <locale>en</locale>
  <locale>it</locale>
</locale-config>

In config.xml i Have:

<edit-config file="AndroidManifest.xml" target="/manifest/supports-screens" mode="merge">
  <supports-screens android:anyDensity="true" android:resizeable="true" 
    android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" 
    android:xlargeScreens="true" />
</edit-config>

<edit-config file="AndroidManifest.xml" target="/manifest/application" mode="merge">
  <application android:localeConfig="@xml/locales_config" />
</edit-config>

Please describe the issue:

Language cannot be selected at Android app language selection

I suspect the problem is using @xml. The resources/xml folder in your project is not the same as the one in the platform. You could either implement a hook to copy the file into the android platform, or use a plugin. I would suggest looking at this plugin, which I think will do what you need: https://www.npmjs.com/package/cordova-plugin-localization-strings

I have this hook-android-before-compile.js file also in the resources/xml folder


var path = require(‘path’);
function copyAndroidFiles() {
const fs = require(‘fs-extra’);
fs.copySync(“resources/xml/locales_config.xml”, “platforms/android/app/src/main/res/xml/locales_config.xml”);
}
module.exports = function(context) {
copyAndroidFiles();
};

Would this work in config.xml?

<platform name="android">
    <resource-file src="resources/xml/locales_config.xml" target="app/src/main/res/xml/locales_config.xml" />
</platform>

(can never figure out how to include code in this forum)

That’s worth a try.

This forum uses markdown. That syntax should work for you. Here’s a reference: Markdown Guide