i18N for Capacitor plugins.
See original GitHub issueAs we have more capacitor plugins and also applications being developed for different locales, having a fixed set of string resource values will make the app not “accessible”
Normally, this is done using storing the localisation strings in the resource table in the native code. I am proposing that the strings be passed as an array during the initialisation of capacitor plugin.
Another issue is that for supporting multiple languages would require having to spend time on creating the resources, reviewing the correctness and committing the changes. This would make the whole process time consuming and lengthy.
I am submitting a RFC for this.
Proposal:
1. A general mechanism for app developers to provide an array of localized strings that
would be passed during the plugin initialization.
2. When a plugin dialog is displayed use the localized strings that were provided to
give a better accessible user experience
3. In case a localization string is not available, fallback to the default 'EN' string.
3.1 In case string was missed, future version of software can have the support added
or provide better localizations.
By having the app developer control over the localised strings it would help develop apps independently without having to depend on commit cycles of native plugin.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:14 (8 by maintainers)
Top GitHub Comments
I’ll propose an alternative solution to this problem
As long as plugins make strings configurable (most have only a handful), the JS layer can use its existing localization solution (Ember, Angular, etc. all have mechanisms for localization already).
Conveniently, this is how most Capacitor plugins already work, for example:
Benefits
EN
vs.en-gb
vs.eng
).Plugins that need to be updated
Here are some plugins that have some elements that aren’t configurable at the moment:
Way forward
Let me know what you think!
ping @jcesarmobile @xmano @TrayserCassa
I have some code changes for the proposal. It is a private repo though:
https://github.com/ionic-team/eauth-integ-test/commit/c9ef8405aa6969a46b3496f2b828bd0d99690b86
The idea is to pass a localise string array to the plugin initialisation code and have the platform render the strings properly when the UI is displayed.