From 369f36ffd546ff44168dcf04437eb140879070d3 Mon Sep 17 00:00:00 2001 From: Thorsten Reiter <34274688+reithor@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:03:36 +0200 Subject: [PATCH] IBX-8502: Added unsupported locale fallback (#171) --- .../Resources/public/js/CKEditor/core/base-ckeditor.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bundle/Resources/public/js/CKEditor/core/base-ckeditor.js b/src/bundle/Resources/public/js/CKEditor/core/base-ckeditor.js index 517d6276..b78a00e3 100644 --- a/src/bundle/Resources/public/js/CKEditor/core/base-ckeditor.js +++ b/src/bundle/Resources/public/js/CKEditor/core/base-ckeditor.js @@ -125,7 +125,15 @@ const VIEWPORT_TOP_OFFSET_DISTRACTION_FREE_MODE = 0; const wrapper = this.getHTMLDocumentFragment(container.closest('.ibexa-data-source').querySelector('textarea').value); const section = wrapper.childNodes[0]; const { toolbar, extraPlugins = [], extraConfig = {} } = window.ibexa.richText.CKEditor; - const locale = new Intl.Locale(doc.querySelector('meta[name="LanguageCode"]').content); + let locale; + try { + locale = new Intl.Locale(doc.querySelector('meta[name="LanguageCode"]').content); + } catch (e) { + console.warn( + `Unsupported LanguageCode '${doc.querySelector('meta[name="LanguageCode"]').content}' - using fallback 'eng-GB'.`, + ); + locale = new Intl.Locale('eng-GB'); + } const blockCustomStyles = Object.entries(ibexa.richText.customStyles) .filter(([, customStyleConfig]) => !customStyleConfig.inline) .map(([customStyleName, customStyleConfig]) => {