-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
i18N for Capacitor plugins. #872
Comments
I have some code changes for the proposal. It is a private repo though: 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. |
Any Updates on that? Because it is very deep interaction with capacitor, so I didn't want to make a pull request and do it on my own. But my Product Owner sad, 'ionic is dead when they can't support local languages'. |
Well, this only affects a few native messages on some plugins. Ionic apps can be totally localized except for those few native Capacitor plugins. It’s still not clear if we will use some common json or if we will use the native implementation per platform. As you said you thought about sending a PR, what would be your approach? |
It should be customizable over a File in the Project and not the native implementation. The cli could ask for a default language at the init function. The sync Function can then clone the data to the native string file. The Problem with directly Native is, that I don't want to care about implementing it twice (Android, iOS). If you answer is, well we do it native, I will be writing my own cli for i18n Transfer. |
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: import { Plugins } from '@capacitor/core';
const { Modals } = Plugins;
// en
Modals.confirm({
title: 'Confirm',
message: 'Are you sure you\'d like to press the red button?',
});
// with translation
Modals.confirm({
title: this.get('locale').translate('modal.confirm'),
message: this.get('locale').translate('modal.confirmBody'),
});
// `this.get('locale')` would be backed by e.g. ember-intl Benefits
Plugins that need to be updatedHere are some plugins that have some elements that aren't configurable at the moment:
Way forward
Let me know what you think! |
Hi, is there any progress on this issue or maybe an workaround? |
Hi, is there any idea when this is gonna be done? |
@SwenVogel and @jalison-dasilva Out of curiosity, would my proposal above work for your use-cases? I.e. does the framework you are using (Ember, React, Vue, etc) have translation support built in or provided via an addon? |
Hi @sandstrom yes definitely the solution that you have proposed it would work for me. |
the user provided strings approach has been implemented for Camera plugin on #2631 |
awesome @jcesarmobile! I think you should close this issue + add a note in the docs about your approach to i18n in plugins:
|
@jcesarmobile For 3.x, maybe you can reconsider my suggestion about localization above? As the Capacitor-endorsed method of handling localization under 3.x plugins. |
Thanks @sandstrom. I'll close this. I created ionic-team/capacitor-site#95 to update the docs. If we're missing configuration options for strings in the official plugins now or in the future, for some reason, please open an issue in the plugins repo for Capacitor 3. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
As 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:
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.
The text was updated successfully, but these errors were encountered: