From 7d6f96a64abee2a739b509f173306945af672af0 Mon Sep 17 00:00:00 2001 From: hemengke1997 <49073282+hemengke1997@users.noreply.github.com> Date: Fri, 7 Apr 2023 10:44:32 +0800 Subject: [PATCH] fix: language kebab case --- playground/spa/src/App.tsx | 9 +++++++++ playground/spa/src/locale/zh-tw/test.json | 3 +++ playground/spa/src/main.tsx | 1 + src/plugin/index.ts | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 playground/spa/src/locale/zh-tw/test.json diff --git a/playground/spa/src/App.tsx b/playground/spa/src/App.tsx index 7c067a8..41d0677 100644 --- a/playground/spa/src/App.tsx +++ b/playground/spa/src/App.tsx @@ -38,6 +38,15 @@ function App() { > 德文 + ) } diff --git a/playground/spa/src/locale/zh-tw/test.json b/playground/spa/src/locale/zh-tw/test.json new file mode 100644 index 0000000..0f126bc --- /dev/null +++ b/playground/spa/src/locale/zh-tw/test.json @@ -0,0 +1,3 @@ +{ + "key": "繁体中文" +} diff --git a/playground/spa/src/main.tsx b/playground/spa/src/main.tsx index 8511464..8adeb5b 100644 --- a/playground/spa/src/main.tsx +++ b/playground/spa/src/main.tsx @@ -27,6 +27,7 @@ i18next interpolation: { escapeValue: false, }, + lowerCaseLng: true, // up to you fallbackLng, detection: { order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator'], diff --git a/src/plugin/index.ts b/src/plugin/index.ts index 55bd6a6..3f8e65c 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -93,7 +93,7 @@ export async function i18nDetector(options: I18nDetectorOptions) { for (const k in modules) { // Currently rollup don't support inline chunkName // TODO: chunk name - code += `${k}: () => import('${VIRTUAL}-${k}'),` + code += `'${k}': () => import('${VIRTUAL}-${k}'),` } code += ' };'