Explicitly force the editor language
authorAlexander Ebert <ebert@woltlab.com>
Fri, 7 Apr 2023 20:23:13 +0000 (22:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 12 Apr 2023 15:15:51 +0000 (17:15 +0200)
CKEditor implicitly detects an available translation, but only if it is defined first. Explicitly setting the language avoids any race conditions that could take place.

ts/WoltLabSuite/Core/Component/Ckeditor/Configuration.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Configuration.js

index cdb871fcbb5b9db63d715fa94d370e09905bee38..5f4e34cf859fafe73c05f2533cf5ff7a6d330cae 100644 (file)
@@ -240,8 +240,11 @@ class ConfigurationBuilder {
   }
 
   toConfig(): EditorConfig {
+    const language = Object.keys(window.CKEDITOR_TRANSLATIONS).find((language) => language !== "en");
+
     // TODO: The typings are both incompleted and outdated.
     return {
+      language,
       removePlugins: this.#removePlugins,
       toolbar: this.#getToolbar(),
       woltlabToolbarGroup: this.#toolbarGroups,
index 6bf78ca6393d0ecd2628ca670073fac45b78badf..542bdde6a62215c418f3c1466b240004065fa960 100644 (file)
@@ -208,8 +208,10 @@ define(["require", "exports", "../../Language"], function (require, exports, Lan
             this.#setupMention();
         }
         toConfig() {
+            const language = Object.keys(window.CKEDITOR_TRANSLATIONS).find((language) => language !== "en");
             // TODO: The typings are both incompleted and outdated.
             return {
+                language,
                 removePlugins: this.#removePlugins,
                 toolbar: this.#getToolbar(),
                 woltlabToolbarGroup: this.#toolbarGroups,