Skip to content
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

Wrong norwegian translation files being used #113

Closed
eddiedale opened this issue Jun 27, 2023 · 5 comments
Closed

Wrong norwegian translation files being used #113

eddiedale opened this issue Jun 27, 2023 · 5 comments
Assignees
Labels

Comments

@eddiedale
Copy link

Description

CKEditor unfortunately currently have two duplicate norwegian language files in use.
With duplicate, I mean that they both refer to the same norwegian dialect (the main "Bokmål" dialect).
The alternate "nn" is not supported, but rather the "no" variant, which basically is the same as "nb".

The problem is that the "no" is the developed language file by CKEditor (see coverage vs "nb" in image below)
image

Since Craft CMS (When using Norwegian Bokmål) uses the standard "nb" language code, it uses the substantially less updated "nb" translation, which causes a lot of lacking translations.

Optimally CKEditor should be using "nn" and "nb", but seeing that there exists no "nn" (Nynorsk) translations, the current best fix seems to be to route both "nn" and "nb" to the "no" translation. This will enhance the experience for all Norwegian CKEditor users.

See issue discussed 10 years ago on CKEditor issue tracking

https://dev.ckeditor.com/ticket/10135

"The simplest fix would simply be to keep the macrolanguage (no) and ditch nb altogether, since there are no Nynorsk translators anyway."

Additional info

  • Craft version: Craft Pro 4.4.14
  • PHP version: 8.2.0
  • Database driver & version: MariaDB 10.4.27
  • Plugins & versions: CKEditor 3.4.0
@eddiedale eddiedale added the bug label Jun 27, 2023
@eddiedale
Copy link
Author

This wouldn't be an issue if one could override in the CKEditor config with language: 'no' but that does not work.

Not respecting language choice in config

If I choose language:'no' in the config, but use "Norwegian Bokmål (nb)" in my user settings in Craft, it still loads the nb.js translation file, not the no.js as wished for.

Not using the loaded translation file

Furthermore, if I use "Norwegian Nynorsk" language in the Craft App, the no.js correctly loads because of the following line (I think?):
https://github.com/craftcms/ckeditor/blob/main/src/web/assets/BaseCkeditorPackageAsset.php#L69

image

But it does not take effect! It defaults back to English language. So even though the language file is loaded, it doesn't seem to get used.

From my little debugging, it seems to be related to the following line in Field.php, defining the ui language based on the Craft App language, not taking into account translation options in the config nor the correctly loaded language file "no" instead of the non existent "nn".
https://github.com/craftcms/ckeditor/blob/main/src/Field.php#L257

image

@i-just i-just self-assigned this Aug 1, 2023
@i-just
Copy link
Contributor

i-just commented Aug 2, 2023

Hi, thanks for reporting and for all the details!

Translations in the ckeditor/src/translations are for the Craft added elements. In the field itself, they’re things like “Link to a category”, “Link to an entry”; outside the field, they’re used on the field settings page and on the CKEditor settings page (where you define your “CKEditor Configs”).

All other translations come from CKEditor itself.

I just raised a PR that makes it possible to use CKE config to choose the language to be used for the CKEditor UI (and content). It can be done via "language": "no" if you wish to change both UI and content language or via

“language": {
	"ui": "no",
	"content": "nb"
}

if you wish to change the UI and content language independently.

I also added the translations/nn/ckeditor.php file, which as a starting point, is a copy of the nb translations, so things like “Link to a category” will display in Norwegian if your app language is set to nn.

@eddiedale
Copy link
Author

This is a really nice solution! Thank you very much! 🙌

@brandonkelly
Copy link
Member

PR merged! I had to remove the config checks as there’s no way that could have applied to plugin-supplied CKEditor bundles. So CKEditor fields will continue to be translated based on the user’s preferred language alone, not based on the editor config. But each of the issues explained here should be resolved.

@brandonkelly
Copy link
Member

CKEditor 3.5.0 is out with this fix 🎉

Note that the update requires Craft 4.5.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants