@dile/editor 2.4.8 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dile/editor",
3
- "version": "2.4.8",
3
+ "version": "2.4.9",
4
4
  "description": "Webcomponent to create a user editor interface, configured on various ways",
5
5
  "keywords": [
6
6
  "markdown",
@@ -41,5 +41,5 @@
41
41
  "prosemirror-state": "^1.4.3",
42
42
  "prosemirror-view": "^1.37.0"
43
43
  },
44
- "gitHead": "8665bccc5f2c06da590d20a3bfd2f7b4c0a7638c"
44
+ "gitHead": "f833a589b4bf56c3a1b46e40d3c5ce364b0facca"
45
45
  }
@@ -1,15 +1,27 @@
1
- import {TranslationService as OriginalTranslationService} from '@dile/ui/mixins/i18n/TranslationService.js';
1
+ import { TranslationService as OriginalTranslationService } from '@dile/ui/mixins/i18n/TranslationService.js';
2
+
3
+ const translations = import.meta.glob('./i18n/*.js', { eager: true });
2
4
 
3
5
  class TranslationService extends OriginalTranslationService {
4
6
  async importLanguage(language) {
5
- const module = await import(`./i18n/${language}.js`);
6
- return module;
7
+ const importPath = `./i18n/${language}.js`;
8
+
9
+ if (translations[importPath]) {
10
+ return translations[importPath];
11
+ } else {
12
+ throw new Error(`Translation file for language "${language}" not found.`);
13
+ }
7
14
  }
8
15
 
9
16
  async importFallback() {
10
- const defaultModule = await import('./i18n/en.js');
11
- return defaultModule;
17
+ const fallbackPath = './i18n/en.js';
18
+
19
+ if (translations[fallbackPath]) {
20
+ return translations[fallbackPath];
21
+ } else {
22
+ throw new Error('Fallback translation file not found.');
23
+ }
12
24
  }
13
25
  }
14
26
 
15
- export const translationService = new TranslationService();
27
+ export const translationService = new TranslationService();