In a Lenovo tablet with Android 13 I noted I can set app-specific languages, but my Cordova applications don’t show up there. Anyone knows what’s needed for it to do that?
I use navigator.language for language selection, but that’s run-time. A static setting (in config.xml or in a plugin) would be needed for the above to work.
At least not only bundled applications show up in the list, so a native Android application should be able to control this, but I don’t find information about that either, unless somehow this is detected automatically if several language resouces have been created as per Support different languages and cultures | Android Developers.
Thanks in advance.
I did a bit of looking around and found this plugin which may help: cordova-plugin-localization-strings - npm
Please let us know if this works for you.
Thanks for the advice.
It seems to work partly.
I’ve followed the instructions to the letter (file structure, including the plugin etc) but APKs don’t contain anything that this plugin is supposed to create during its initialization, which in this case would be files created during your building process (might there be a conflict at that stage?). The IPA does though (more below).
I have created en.json and se.json under translations/app, with content that these files are supposed to contain. Example (en.json):
"NSCameraUsageDescription": "The app needs permission to the camera to scan barcodes",
"NSPhotoLibraryUsageDescription": "The app needs permission to the album to store pictures",
"NSLocationWhenInUseUsageDescription": "The app needs permission to position the device",
"NFCReaderUsageDescription": "The app needs permission to read NFC tags",
I don’t get any error message for either build.
This in the log indicates it captured the language-specific files:
Pbx project written with localization groups [ ‘se’, ‘en’ ]
It also does generate xx.lproj filders per language for iOS.
I will continue evaluation.
Speculation, but this might be the reason there are no localization files in the APK. This is where localizations are created, and they are not part of the resulting APK.
Localization saved: /platforms/android/app/src/main/res/values-se/strings.xml
Localization saved: /platforms/android/app/src/main/res/values/strings.xml
I’ll contact the plugin author to see if they are aware of this or maybe this only affects cloud builds somehow.
This might be what actually makes Android consider an app to have multiple languages, which is not handled by this plugin nor Cordova core (apparently):
Please let us know what the author of the plugin has to say. If the build.gradle needs modifications it’s possible we can help if the modifications are specific enough. We do similar things for Capacitor.
Alright. I’ll let you know.