The dialog title for inserting media items from the media library is not translated on a multilingual setup.
Tested on a fresh install, the old Ckeditor shows the title in the correct language.
The dialog title when using Ckeditor 5 is always "Add or select media", disregarding the interface language.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | interdiff.txt | 1.43 KB | lauriii |
| #28 | 3347212-28.patch | 2 KB | lauriii |
| #27 | mediaLibrary-dialog-from-editor-title-translatable-3347212-4.patch | 1.44 KB | wim leers |
| #23 | 3347212-23.patch | 3.27 KB | miikamakarainen |
| #21 | dutch translation.png | 53.11 KB | miikamakarainen |
Comments
Comment #2
sakthi_dev commentedComment #3
sakthi_dev commentedCreated a patch for translating the title of media library dialog after enabling it for text format. Attached the screenshot as well. Please review.
Comment #4
sakthi_dev commentedComment #5
miikamakarainen commentedTested patch in #3, the translation works now as intended.
I removed the title attribute for said dialog from ckeditor5.ckeditor5.yml as I believe that value is now not used at all, I also simplified the patch a bit.
Comment #6
smustgrave commentedThank you for reporting the issue.
Next step will be to get a test assertion in place to check that it's properly translated.
Comment #7
miikamakarainen commentedI'm not too familiar with testing but should this test regarding if the translation works be done in the core media_library module instead?
In the core media_library module there is tests regarding if the library translation works as intended, the current translation test has call to waitForText('Add or select media') in both dutch and spanish, by updating them to the correct translated strings the test should fail if the strings are not translated.
Attached a patch regarding proposed change but this should perhaps be moved to a separate issue regarding the media_library module, not ckeditor5.
Comment #8
ameymudras commentedComment #9
ameymudras commentedComment #10
smustgrave commented@ameymudras that's the test-only patch FYI that you're carrying forward.
@miikamakarainen if that's where you want to place them you should use the
t()function. So we don't have to pull cspell ignroes in.Comment #11
miikamakarainen commented@smustgrave if I have understood things correct the test in media_library will fail when the dialog is patched so it needs updating either way as waitForText('Add or select media') will not be in english when the string is translated.
Attached an updated patch which checks if the ui dialog is translated correctly and waits for the element instead of the dialog title text.
Comment #12
smustgrave commentedCorrect but when you use the t('Add or select media') it will check for the translated string. Or else we have to cspell ignore those specific lines as they are failing the custom commands.
Comment #13
borisson_I disagree with using t in the tests themselves. See https://www.drupal.org/project/drupal/issues/2875148 for background info
Comment #14
anchal_gupta commentedI have uploaded the patch
Fixed CCF
Comment #15
smustgrave commentedBut in this scenario we are testing translations
Hiding 14 as it removes the fix to the problem.
Comment #16
wim leersI was going to say "but CKEditor 5 plugin labels are translatable and they're also defined in that YAML file, so why don't these work?"
The answer:
\Drupal\ckeditor5\Annotation\DrupalAspectsOfCKEditor5Plugin::$labelhas:Such annotations are not possible for each plugin's custom metadata…
So +1 for this.
#13: I think @smustgrave is right in #15 — see
\Drupal\Tests\ckeditor5\FunctionalJavascript\LanguageTest::test()for example 😅Just add
above this line.
Same here.
… then this will pass tests and I'll RTBC 😊
Comment #17
Yogesh Sahu commentedmake changes as per #16
Comment #18
Yogesh Sahu commentedComment #20
nikhil_110 commentedAttempted to fix error patch #17
Comment #21
miikamakarainen commentedUpdated the patch from #11 according to #16 (skipped #17 and #20 as they introduced a typo in the spellings).
I'm a bit worried that this patch wont pass the testing procedure somehow as the previous test results have failed and that is because the string has been in English in the testing environment. Attached screenshots from my local environment just to verify that the strings are correct and the translation part of the patch works.
If the tests fails with due to asserting the strings, could it be so that the testing environment does not have the dutch or spanish localization strings available? If so, then we cannot test that this string has been translated.
Comment #22
miikamakarainen commentedAdding accidentally stripped space which corrupted the patch in #21.
Comment #23
miikamakarainen commentedRe-roll of patch #22
Comment #24
wim leers#23 will not apply because it was relative to
web/core, notcore.But you're right, even after enabling the
localemodule, the translation test is not working. In hindsight, I was wrong in #16 — because\Drupal\Tests\ckeditor5\FunctionalJavascript\LanguageTest::test()is testing CKEditor 5's UI translations, not Drupal's!So per #2875148: BrowserTestBase: Steer new test development away from translation, we AFAICT should simply not have any test coverage for this. Is that right, @borisson_?
Comment #25
miikamakarainen commentedIf we are not to test any translations then the patch in #5 should be ok and it has passed testing. We do not need to update the media_library tests as the ui elements (in the testing environment) are unaffected by this change.
Comment #26
borisson_Yes, this was also discussed in slack, and catch agreed that there is no test coverage needed. So #5 should be correct patch here.
Comment #27
wim leersRe-uploading #5 🤓
Comment #28
lauriiiThis should address the failing custom commands.
Comment #32
larowlanCommitted to 10.1.x. and backported to 10.0.x and 9.5.x
Thanks all