@dile/crud
Advanced tools
Comparing version 0.6.12 to 0.6.13
import { TranslationService as OriginalTranslationService } from '@dile/ui/mixins/i18n/TranslationService.js'; | ||
const translations = import.meta.glob('./i18n/*.js', { eager: true }); | ||
class TranslationService extends OriginalTranslationService { | ||
async importLanguage(language) { | ||
const importPath = `./i18n/${language}.js`; | ||
if (translations[importPath]) { | ||
return translations[importPath]; | ||
} else { | ||
throw new Error(`Translation file for language "${language}" not found.`); | ||
switch (language) { | ||
case 'es': | ||
return import('./i18n/es.js'); | ||
case 'en': | ||
return import('./i18n/en.js'); | ||
default: | ||
throw new Error(`Unsupported language: ${language}`); | ||
} | ||
@@ -17,7 +16,5 @@ } | ||
async importFallback() { | ||
const fallbackPath = './i18n/en.js'; | ||
if (translations[fallbackPath]) { | ||
return translations[fallbackPath]; | ||
} else { | ||
try { | ||
return import('./i18n/en.js'); | ||
} catch (error) { | ||
throw new Error('Fallback translation file not found.'); | ||
@@ -24,0 +21,0 @@ } |
{ | ||
"name": "@dile/crud", | ||
"version": "0.6.12", | ||
"version": "0.6.13", | ||
"description": "Components to create a generic crud system based on Web Components and Lit", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "ddbdaed2692688f0fcdb6d30bfae38fcda5a1e0c" | ||
"gitHead": "835b290fb9a8796a94961f2dfe779b4e61446bb8" | ||
} |
131862