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: switching language does not load the translation of the components library #4205

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion apps/web-antd/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
});
}

export { $t, antdLocale, loadMessages, setupI18n };
export { $t, antdLocale, setupI18n };
2 changes: 1 addition & 1 deletion apps/web-ele/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
});
}

export { $t, elementLocale, loadMessages, setupI18n };
export { $t, elementLocale, setupI18n };
2 changes: 1 addition & 1 deletion apps/web-naive/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
});
}

export { $t, loadMessages, setupI18n };
export { $t, setupI18n };
7 changes: 0 additions & 7 deletions packages/locales/src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import type {
import { type App, unref } from 'vue';
import { createI18n } from 'vue-i18n';

const loadedLanguages = new Set<string>();

const i18n = createI18n({
globalInjection: true,
legacy: false,
Expand Down Expand Up @@ -78,10 +76,6 @@ async function loadLocaleMessages(lang: SupportedLanguagesType) {
return setI18nLanguage(lang);
}

if (loadedLanguages.has(lang)) {
return setI18nLanguage(lang);
}

const message = await localesMap[lang]?.();

if (message?.default) {
Expand All @@ -91,7 +85,6 @@ async function loadLocaleMessages(lang: SupportedLanguagesType) {
const mergeMessage = await loadMessages(lang);
i18n.global.mergeLocaleMessage(lang, mergeMessage);

loadedLanguages.add(lang);
return setI18nLanguage(lang);
}

Expand Down
2 changes: 1 addition & 1 deletion playground/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ async function setupI18n(app: App, options: LocaleSetupOptions = {}) {
});
}

export { $t, antdLocale, loadMessages, setupI18n };
export { $t, antdLocale, setupI18n };
Loading