Unverified Commit 414c7a4c authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3250191 by nod_, Wim Leers, lauriii, rkoller, Joachim Namyslo:...

Issue #3250191 by nod_, Wim Leers, lauriii, rkoller, Joachim Namyslo: Translation of toolbar button tooltips not working when text part language plugin is enabled
parent 3194ddf3
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -367,25 +367,22 @@
     */
    attach(element, format) {
      const { editorClassic } = CKEditor5;
      const {
        toolbar,
        plugins,
        config: pluginConfig,
        language,
      } = format.editorSettings;
      const { toolbar, plugins, config, language } = format.editorSettings;
      const extraPlugins = selectPlugins(plugins);

      const config = {
      const pluginConfig = processConfig(config);
      const editorConfig = {
        extraPlugins,
        toolbar,
        language,
        ...processConfig(pluginConfig),
        ...pluginConfig,
        // Language settings have a conflict between the editor localization
        // settings and the "language" plugin.
        language: { ...pluginConfig.language, ...language },
      };
      // Set the id immediately so that it is available when onChange is called.
      const id = setElementId(element);
      const { ClassicEditor } = editorClassic;

      ClassicEditor.create(element, config)
      ClassicEditor.create(element, editorConfig)
        .then((editor) => {
          // Save a reference to the initialized instance.
          Drupal.CKEditor5Instances.set(id, editor);
+8 −5
Original line number Diff line number Diff line
@@ -161,21 +161,24 @@
      const {
        toolbar,
        plugins,
        config: pluginConfig,
        config,
        language
      } = format.editorSettings;
      const extraPlugins = selectPlugins(plugins);
      const config = {
      const pluginConfig = processConfig(config);
      const editorConfig = {
        extraPlugins,
        toolbar,
        language,
        ...processConfig(pluginConfig)
        ...pluginConfig,
        language: { ...pluginConfig.language,
          ...language
        }
      };
      const id = setElementId(element);
      const {
        ClassicEditor
      } = editorClassic;
      ClassicEditor.create(element, config).then(editor => {
      ClassicEditor.create(element, editorConfig).then(editor => {
        Drupal.CKEditor5Instances.set(id, editor);

        if (element.hasAttribute('required')) {
+18 −8
Original line number Diff line number Diff line
@@ -29,18 +29,20 @@ class LanguageTest extends CKEditor5TestBase {
   *
   * @param string $langcode
   *   The language code.
   * @param string $blockquote_translation
   *   The expected translation for blockquote toolbar button.
   * @param string $toolbar_item_name
   *   The CKEditor 5 plugin to enable.
   * @param string $toolbar_item_translation
   *   The expected translation for CKEditor 5 plugin toolbar button.
   *
   * @dataProvider provider
   */
  public function test(string $langcode, string $blockquote_translation): void {
  public function test(string $langcode, string $toolbar_item_name, string $toolbar_item_translation): void {
    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->createNewTextFormat($page, $assert_session);
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ckeditor5-toolbar-item-blockQuote'));
    $this->triggerKeyUp('.ckeditor5-toolbar-item-blockQuote', 'ArrowDown');
    $this->assertNotEmpty($assert_session->waitForElement('css', ".ckeditor5-toolbar-item-$toolbar_item_name"));
    $this->triggerKeyUp(".ckeditor5-toolbar-item-$toolbar_item_name", 'ArrowDown');
    $assert_session->assertWaitOnAjaxRequest();
    $this->saveNewTextFormat($page, $assert_session);

@@ -50,7 +52,7 @@ public function test(string $langcode, string $blockquote_translation): void {
    $this->drupalGet('node/add');
    $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
    // Ensure that blockquote button is translated.
    $assert_session->elementExists('xpath', "//span[text()='$blockquote_translation']");
    $assert_session->elementExists('xpath', "//span[text()='$toolbar_item_translation']");
  }

  /**
@@ -62,11 +64,19 @@ public function provider(): array {
    return [
      'Language code both in Drupal and CKEditor' => [
        'langcode' => 'th',
        'blockquote_translation' => 'คำพูดบล็อก',
        'toolbar_item_name' => 'blockQuote',
        'toolbar_item_translation' => 'คำพูดบล็อก',
      ],
      'Language code transformed from browser mappings' => [
        'langcode' => 'zh-hans',
        'blockquote_translation' => '块引用',
        'toolbar_item_name' => 'blockQuote',
        'toolbar_item_translation' => '块引用',
      ],
      'Language configuration conflict' => [
        'langcode' => 'fr',
        'toolbar_item_name' => 'textPartLanguage',
        // cSpell:disable-next-line
        'toolbar_item_translation' => 'Choisir la langue',
      ],
    ];
  }