Comments

miikamakarainen created an issue. See original summary.

sakthi_dev’s picture

Assigned: Unassigned » sakthi_dev
sakthi_dev’s picture

Created a patch for translating the title of media library dialog after enabling it for text format. Attached the screenshot as well. Please review.

sakthi_dev’s picture

Assigned: sakthi_dev » Unassigned
Status: Active » Needs review
miikamakarainen’s picture

Tested 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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

Thank you for reporting the issue.

Next step will be to get a test assertion in place to check that it's properly translated.

miikamakarainen’s picture

Status: Needs work » Needs review
StatusFileSize
new1.42 KB

I'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.

ameymudras’s picture

StatusFileSize
new2.09 KB
new600 bytes
ameymudras’s picture

StatusFileSize
new2.18 KB
new692 bytes
smustgrave’s picture

Status: Needs review » Needs work

@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.

miikamakarainen’s picture

Status: Needs work » Needs review
StatusFileSize
new3.16 KB

@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.

smustgrave’s picture

Status: Needs review » Needs work

Correct 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.

borisson_’s picture

Correct 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.

I disagree with using t in the tests themselves. See https://www.drupal.org/project/drupal/issues/2875148 for background info

anchal_gupta’s picture

StatusFileSize
new3.17 KB
new1.64 KB

I have uploaded the patch
Fixed CCF

smustgrave’s picture

But in this scenario we are testing translations

Hiding 14 as it removes the fix to the problem.

wim leers’s picture

Issue tags: -Needs tests +translation

I 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::$label has:

  /**
   * The human-readable name of the CKEditor plugin.
   *
   * @var \Drupal\Core\Annotation\Translation
   * @ingroup plugin_translatable
   */
  public $label;

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 😅


  1. +++ b/core/modules/media_library/tests/src/FunctionalJavascript/TranslationsTest.php
    @@ -151,7 +151,9 @@ public function testMediaLibraryTranslations() {
    +    $this->assertSame('Media toevoegen of selecteren', $header_text);
    

    Just add

    // cSpell:disable-next-line
    

    above this line.

  2. +++ b/core/modules/media_library/tests/src/FunctionalJavascript/TranslationsTest.php
    @@ -164,7 +166,9 @@ public function testMediaLibraryTranslations() {
    +    $this->assertSame('Añadir o seleccionar medio', $header_text);
    

    Same here.

… then this will pass tests and I'll RTBC 😊

Yogesh Sahu’s picture

StatusFileSize
new3.24 KB
new1.39 KB

make changes as per #16

Yogesh Sahu’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 17: 3347212-17.patch, failed testing. View results

nikhil_110’s picture

StatusFileSize
new857 bytes
new3.21 KB

Attempted to fix error patch #17

miikamakarainen’s picture

StatusFileSize
new45.87 KB
new53.11 KB
new3.28 KB

Updated 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.

miikamakarainen’s picture

StatusFileSize
new3.28 KB

Adding accidentally stripped space which corrupted the patch in #21.

miikamakarainen’s picture

StatusFileSize
new3.27 KB

Re-roll of patch #22

wim leers’s picture

#23 will not apply because it was relative to web/core, not core.

But you're right, even after enabling the locale module, 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_?

miikamakarainen’s picture

If 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.

borisson_’s picture

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_?

Yes, this was also discussed in slack, and catch agreed that there is no test coverage needed. So #5 should be correct patch here.

wim leers’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.44 KB

Re-uploading #5 🤓

lauriii’s picture

StatusFileSize
new2 KB
new1.43 KB

This should address the failing custom commands.

  • larowlan committed f8c9f1fe on 10.0.x
    Issue #3347212 by miikamakarainen, sakthi_dev, Yogesh Sahu, lauriii,...

  • larowlan committed 492594cb on 10.1.x
    Issue #3347212 by miikamakarainen, sakthi_dev, Yogesh Sahu, lauriii,...

  • larowlan committed ce1f04c8 on 9.5.x
    Issue #3347212 by miikamakarainen, sakthi_dev, Yogesh Sahu, lauriii,...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 10.1.x. and backported to 10.0.x and 9.5.x

Thanks all

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.