Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switch to use dynamic mixin #2086

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 5 additions & 68 deletions lang/localize-core-element.js
Original file line number Diff line number Diff line change
@@ -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
};
}

};