You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/02/11 08:07:59 UTC
[GitHub] [cordova-android] ath0mas opened a new issue #1396: Locales: setup `resConfigs` in template and update it in project when `defaultlocale` is defined
ath0mas opened a new issue #1396:
URL: https://github.com/apache/cordova-android/issues/1396
# Feature Request
## Motivation Behind Feature
<!-- Why should this feature be implemented? What problem does it solve? -->
`resConfigs` is a property that may be added into the app's `build.gradle`.
To mimic what's done in cordova-ios (see some details in https://github.com/apache/cordova-ios/issues/1222) I suggest to setup `resConfigs`, giving it the value `en`, and then if the `defaultlocale="XX"` attribute is defined onto the `widget` tag in config.xml to update it to a different language.
## Feature Description
<!--
Describe your feature request in detail
Please provide any code examples or screenshots of what this feature would look like
Are there any drawbacks? Will this break anything for existing users?
-->
`resConfigs` mostly [specifies the supported languages](https://developer.android.com/guide/topics/resources/multilingual-support#specify-the-languages-your-app-supports), and relates to [shrinking and optimizing](https://developer.android.com/studio/build/shrink-code#unused-alt-resources) too.
I think it would be good to set it in the template `build.gradle` [here](https://github.com/apache/cordova-android/blob/master/templates/project/app/build.gradle#L182), so that any resources for other languages are removed at build time.
The base value may be `en` like what is done in cordova-ios ([here](https://github.com/apache/cordova-ios/blob/master/templates/project/__PROJECT_NAME__/__PROJECT_NAME__-Info.plist#L6) and [there](https://github.com/apache/cordova-ios/blob/master/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj#L236)).
With a single language it does not change much things except shrinking and optimizing.
Then it would be necessary to support and apply the `defaultlocale` attribute if defined onto the `widget` tag in _config.xml_ so that a different language can override the hardcoded `en` inherited from the template files.
This `resConfig` is really important to define as soon as multiple languages are pushed to the project, like when using [cordova-plugin-localization-strings](https://github.com/kelvinhokk/cordova-plugin-localization-strings). Indeed without it you often end up with the app language "strangely" resolved by the system: see this really good [blog](https://medium.com/@hectorricardomendez/how-to-get-the-current-locale-in-android-fc12d8be6242).
The _localization-strings_ plugin may support it too soon? through https://github.com/kelvinhokk/cordova-plugin-localization-strings/issues/65.
## Alternatives or Workarounds
<!--
Describe alternatives or workarounds you are currently using
Are there ways to do this with existing functionality?
-->
Custom script after platform add.
Or should I start a new cordova-plugin to add more defaults like this about locales? (to include https://github.com/apache/cordova-ios/issues/1222, https://github.com/kelvinhokk/cordova-plugin-localization-strings/issues/65, and more?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org