From 3e990dddb5b71f2704fa8d178a19984d0d704138 Mon Sep 17 00:00:00 2001 From: icarus Date: Thu, 23 Oct 2025 13:40:14 +0800 Subject: [PATCH] feat(i18n): enhance i18next configuration and vscode settings - Add new i18next config options including defaultValue, primaryLanguage, and types generation - Update vscode settings for better i18n-ally integration and namespace support - Reorder search exclude patterns for consistency --- .vscode/settings.json | 7 ++++--- i18next.config.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9fe4ec4bb4..95f7ec1898 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -35,19 +35,20 @@ ".oxlintrc.json": "jsonc" }, "files.eol": "\n", + "i18n-ally.defaultNamespace": "translation", // "i18n-ally.displayLanguage": "zh-cn", // 界面显示语言 "i18n-ally.enabledFrameworks": ["react-i18next", "i18next"], "i18n-ally.enabledParsers": ["ts", "js", "json"], // 解析语言 "i18n-ally.fullReloadOnChanged": true, "i18n-ally.keystyle": "nested", // 翻译路径格式 "i18n-ally.localesPaths": ["src/renderer/src/i18n/locales"], - // "i18n-ally.namespace": true, // 开启命名空间 + "i18n-ally.namespace": true, // 开启命名空间 "i18n-ally.sortKeys": true, // 排序 "i18n-ally.sourceLanguage": "zh-cn", // 翻译源语言 "i18n-ally.usage.derivedKeyRules": ["{key}_one", "{key}_other"], // 标记单复数形式的键为已翻译 "search.exclude": { - "**/dist/**": true, - ".yarn/releases/**": true + ".yarn/releases/**": true, + "**/dist/**": true }, "tailwindCSS.classAttributes": [ "className", diff --git a/i18next.config.ts b/i18next.config.ts index 2178cfd88e..271dd98b84 100644 --- a/i18next.config.ts +++ b/i18next.config.ts @@ -1,9 +1,19 @@ import { defineConfig } from 'i18next-cli' +/** @see https://github.com/i18next/i18next-cli */ export default defineConfig({ locales: ['en-us', 'zh-cn', 'zh-tw'], extract: { input: 'src/renderer/src/**/*.{ts,tsx}', - output: 'src/renderer/src/i18n/locales/{{language}}.json' + output: 'src/renderer/src/i18n/locales/{{language}}.json', + defaultValue: '__MISSING_KEY__', + primaryLanguage: 'en-us', + removeUnusedKeys: false + }, + types: { + input: ['src/renderer/src/i18n/locales/en-us.json'], + output: 'src/renderer/src/i18n/i18next.d.ts', + resourcesFile: 'src/renderer/src/i18n/resources.d.ts', + enableSelector: true } })