Skip to content
Snippets Groups Projects
Unverified Commit 1aaaa870 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

(cherry picked from commit bb3ee2e9)
parent bfbf08c0
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -195,19 +195,21 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
var _format$editorSetting = format.editorSettings,
toolbar = _format$editorSetting.toolbar,
plugins = _format$editorSetting.plugins,
pluginConfig = _format$editorSetting.config,
config = _format$editorSetting.config,
language = _format$editorSetting.language;
var extraPlugins = selectPlugins(plugins);
var pluginConfig = processConfig(config);
var config = _objectSpread({
var editorConfig = _objectSpread(_objectSpread({
extraPlugins: extraPlugins,
toolbar: toolbar,
language: language
}, processConfig(pluginConfig));
toolbar: toolbar
}, pluginConfig), {}, {
language: _objectSpread(_objectSpread({}, pluginConfig.language), language)
});
var id = setElementId(element);
var ClassicEditor = editorClassic.ClassicEditor;
ClassicEditor.create(element, config).then(function (editor) {
ClassicEditor.create(element, editorConfig).then(function (editor) {
Drupal.CKEditor5Instances.set(id, editor);
if (element.hasAttribute('required')) {
......
......@@ -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',
],
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment