Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(desktop): drop root-absolute antd locale glob so zh-CN resolves (#18627)

Innei70a1e6aa7094
diff --git a/src/utils/locale.desktop.ts b/src/utils/locale.desktop.ts
deleted file mode 100644
index 784e879ff2f..00000000000
--- a/src/utils/locale.desktop.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { normalizeLocale } from '@/locales/resources';
-
-const antdLocaleLoaders = import.meta.glob(
- '/node_modules/antd/es/locale/{ar_EG,bg_BG,de_DE,en_US,es_ES,fa_IR,fr_FR,it_IT,ja_JP,ko_KR,nl_NL,pl_PL,pt_BR,ru_RU,tr_TR,vi_VN,zh_CN,zh_TW}.js',
-);
-
-export const getAntdLocale = async (lang?: string) => {
- let normalLang: any = normalizeLocale(lang);
-
- // due to antd only have ar-EG locale, we need to convert ar to ar-EG
- // refs: https://ant.design/docs/react/i18n
- if (normalLang === 'ar') normalLang = 'ar-EG';
-
- const localePath = `/node_modules/antd/es/locale/${normalLang.replace('-', '_')}.js`;
- const loadLocale = antdLocaleLoaders[localePath];
-
- if (!loadLocale) {
- throw new Error(`Unsupported antd locale: ${normalLang}`);
- }
-
- const mod = (await loadLocale()) as Record<string, unknown>;
- return mod.default;
-};
diff --git a/src/utils/locale.desktop.test.ts b/src/utils/locale.vite.test.ts
similarity index 88%
rename from src/utils/locale.desktop.test.ts
rename to src/utils/locale.vite.test.ts
index 50f4f23aa4a..eebf3162587 100644
--- a/src/utils/locale.desktop.test.ts
+++ b/src/utils/locale.vite.test.ts
@@ -17,9 +17,9 @@ vi.mock('antd/es/locale/zh_CN.js', () => {
return { default: { locale: 'zh-cn' } };
});
-describe('getAntdLocale.desktop', () => {
+describe('getAntdLocale.vite', () => {
it('evaluates only the requested antd locale', async () => {
- const { getAntdLocale } = await import('./locale.desktop');
+ const { getAntdLocale } = await import('./locale.vite');
expect(moduleEvaluation.english).not.toHaveBeenCalled();
expect(moduleEvaluation.simplifiedChinese).not.toHaveBeenCalled();