From 30105e63684ca1561ea0166aad34c4adf7005c4f Mon Sep 17 00:00:00 2001 From: Dave Lockhart Date: Mon, 7 Feb 2022 11:23:47 -0500 Subject: [PATCH] fix: switch to use dynamic mixin --- lang/localize-core-element.js | 73 +++-------------------------------- 1 file changed, 5 insertions(+), 68 deletions(-) diff --git a/lang/localize-core-element.js b/lang/localize-core-element.js index 54356f46487..105e1358ab5 100644 --- a/lang/localize-core-element.js +++ b/lang/localize-core-element.js @@ -1,74 +1,11 @@ -import { LocalizeMixin } from '../mixins/localize-mixin.js'; +import { LocalizeDynamicMixin } from '../mixins/localize-dynamic-mixin.js'; -export const LocalizeCoreElement = superclass => class extends LocalizeMixin(superclass) { +export const LocalizeCoreElement = superclass => class extends LocalizeDynamicMixin(superclass) { - static async getLocalizeResources(langs) { - let translations; - for await (const lang of langs) { - switch (lang) { - case 'ar': - translations = await import('./ar.js'); - break; - case 'cy': - translations = await import('./cy.js'); - break; - case 'da': - translations = await import('./da.js'); - break; - case 'de': - translations = await import('./de.js'); - break; - case 'en': - translations = await import('./en.js'); - break; - case 'es-es': - translations = await import('./es-es.js'); - break; - case 'es': - translations = await import('./es.js'); - break; - case 'fr-fr': - translations = await import('./fr-fr.js'); - break; - case 'fr': - translations = await import('./fr.js'); - break; - case 'ja': - translations = await import('./ja.js'); - break; - case 'ko': - translations = await import('./ko.js'); - break; - case 'nl': - translations = await import('./nl.js'); - break; - case 'pt': - translations = await import('./pt.js'); - break; - case 'sv': - translations = await import('./sv.js'); - break; - case 'tr': - translations = await import('./tr.js'); - break; - case 'zh-tw': - translations = await import('./zh-tw.js'); - break; - case 'zh': - translations = await import('./zh.js'); - break; - } - if (translations && translations.default) { - return { - language: lang, - resources: translations.default - }; - } - } - translations = await import('./en.js'); + static get localizeConfig() { return { - language: 'en', - resources: translations.default + importFunc: async lang => (await import(`./${lang}.js`)).default }; } + };