Hello,
Problem/Motivation
I realized that the inline_quote ckeditor5 plugin label is not localized after a customer requested that the tooltip "Inline quote" should be translated in the website language.
For instance, my website is in french, so the plugin tooltip should display "Citation en ligne" instead of "Inline quote".
Although it is no big deal since it has no impact on the functionality itself, I believe it would be a nice add-on to enhance the user experience.
Proposed resolution
Since the plugin is using CKEditor t() function already, it would be quite easy to add support for a few translations since there is an automatic discovery of CKEditor plugin translations (see https://www.drupal.org/node/3264983).
Adding a dependency to core/ckeditor5.translations library to inline_quote library and creating the files /js/build/translations/{my_language}.js seems to be enough to solve it.
I'm attaching a patch with the feature request and a few language translations.
Remaining tasks
Add more languages support.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | ckeditor5_inline_quote_make_plugin_translatable.patch | 1.9 KB | misterdidi |
Issue fork ckeditor5_inline_quote-3556621
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3556621-make-plugin-translatable
changes, plain diff MR !5
- 3556621-use-drupal-t
changes, plain diff MR !6
Comments
Comment #2
misterdidi commentedComment #4
mably commentedWondering if using
Drupal.t()couldn't be a better solution here... (MR 6).Anyway, I updated the MR to parse the plugin javascript code and automatically create the translation files using the contributed
<lang>.pofiles.Comment #6
mably commented@misterdidi tell me if it works for you and which solution you prefer.
Comment #8
misterdidi commented@mably, thanks for the quick reply and the MRs.
Tested both solutions and both of them work well!
Although the
Drupal.t()solution is more straightforward, I'd rather stick to the "lang" folder solution to keep it consistent with the way plugins and translations are defined in CKEditor5.Comment #9
mably commented@misterdidi ok, let's merge MR 5 then.
But what if a user wants to override a translation bundled with our plugin. How can it be done?
Comment #10
misterdidi commentedThat's the problem, no CKeditor plugin translation can be overriden in Drupal back-office. :-/
I guess that's why you came up with MR 5 and MR 6 :
I'll leave it to you to decide whether to merge MR 5 or MR 6. As mentioned, I tested both and both work. I only favored the "CKEditor way" for consistency.
Comment #12
mably commentedComment #14
mably commentedThanks @misterdidi.
Fix included in 1.1.0-rc1 release.
Comment #15
misterdidi commentedGreat, thank you !