mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Set the language of the CKEDITOR5 elements based on the page locale.
This commit is contained in:
parent
63b7e0458c
commit
b18284cfd7
3 changed files with 19 additions and 7 deletions
|
@ -28,7 +28,11 @@ export default class extends Controller {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EDITOR_TYPE.create(this.element)
|
const language = document.body.dataset.locale ?? "en";
|
||||||
|
|
||||||
|
EDITOR_TYPE.create(this.element, {
|
||||||
|
language: language,
|
||||||
|
})
|
||||||
.then(editor => {
|
.then(editor => {
|
||||||
if(this.element.disabled) {
|
if(this.element.disabled) {
|
||||||
editor.enableReadOnlyMode("readonly");
|
editor.enableReadOnlyMode("readonly");
|
||||||
|
@ -39,8 +43,8 @@ export default class extends Controller {
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
/* const watchdog = new EditorWatchdog();
|
const watchdog = new EditorWatchdog();
|
||||||
watchdog.setCreator((elementOrData, editorConfig) => {
|
watchdog.setCreator((elementOrData, editorConfig) => {
|
||||||
return EDITOR_TYPE.create(elementOrData, editorConfig)
|
return EDITOR_TYPE.create(elementOrData, editorConfig)
|
||||||
.then(editor => {
|
.then(editor => {
|
||||||
|
@ -56,7 +60,8 @@ export default class extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
watchdog.create(this.element, {
|
watchdog.create(this.element, {
|
||||||
|
}).catch(error => {
|
||||||
|
console.error(error);
|
||||||
}); */
|
}); */
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -51,9 +51,15 @@
|
||||||
{% block javascripts %}
|
{% block javascripts %}
|
||||||
{{ encore_entry_script_tags('app') }}
|
{{ encore_entry_script_tags('app') }}
|
||||||
{{ encore_entry_script_tags('ru2ftwofactor') }}
|
{{ encore_entry_script_tags('ru2ftwofactor') }}
|
||||||
|
|
||||||
|
{# load translation files for ckeditor #}
|
||||||
|
{% set two_chars_locale = app.request.locale|default("en")|slice(0,2) %}
|
||||||
|
{% if two_chars_locale != "en" %}
|
||||||
|
<script src="{{ asset("build/ckeditor_translations/" ~ two_chars_locale ~ ".js") }}"></script>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body data-base-url="{{ url('homepage', {'_locale': app.request.locale}) }}">
|
<body data-base-url="{{ url('homepage', {'_locale': app.request.locale}) }}" data-locale="{{ app.request.locale|default("en")|slice(0,2) }}">
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<header>
|
<header>
|
||||||
<turbo-frame id="navbar-frame" target="content" data-turbo-action="advance">
|
<turbo-frame id="navbar-frame" target="content" data-turbo-action="advance">
|
||||||
|
|
|
@ -131,7 +131,8 @@ Encore
|
||||||
// See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
|
// See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
|
||||||
language: 'en',
|
language: 'en',
|
||||||
addMainLanguageTranslationsToAllAssets: true,
|
addMainLanguageTranslationsToAllAssets: true,
|
||||||
additionalLanguages: 'all'
|
additionalLanguages: 'all',
|
||||||
|
outputDirectory: 'ckeditor_translations'
|
||||||
} ) )
|
} ) )
|
||||||
|
|
||||||
// Use raw-loader for CKEditor 5 SVG files.
|
// Use raw-loader for CKEditor 5 SVG files.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue