@dile/crud
Advanced tools
Comparing version 0.6.8 to 0.6.9
@@ -1,14 +0,24 @@ | ||
import {TranslationService as OriginalTranslationService} from '@dile/ui/mixins/i18n/TranslationService.js'; | ||
import { TranslationService as OriginalTranslationService } from '@dile/ui/mixins/i18n/TranslationService.js'; | ||
const translations = import.meta.glob('./i18n/*.js', { eager: true }) | ||
const translations = import.meta.glob('./i18n/*.js', { eager: true }); | ||
class TranslationService extends OriginalTranslationService { | ||
async importLanguage(language) { | ||
const module = await import(`./i18n/${language}.js`); | ||
return module; | ||
const importPath = `./i18n/${language}.js`; | ||
if (translations[importPath]) { | ||
return translations[importPath]; | ||
} else { | ||
throw new Error(`Translation file for language "${language}" not found.`); | ||
} | ||
} | ||
async importFallback() { | ||
const defaultModule = await import('./i18n/en.js'); | ||
return defaultModule; | ||
const fallbackPath = './i18n/en.js'; | ||
if (translations[fallbackPath]) { | ||
return translations[fallbackPath]; | ||
} else { | ||
throw new Error('Fallback translation file not found.'); | ||
} | ||
} | ||
@@ -15,0 +25,0 @@ } |
{ | ||
"name": "@dile/crud", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"description": "Components to create a generic crud system based on Web Components and Lit", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "d62d281604d5206d27f5c2443e9a312443530140" | ||
"gitHead": "4206a26c8acdf404ecc53cacec8f801b4288b63f" | ||
} |
132003
4008