From e8fca094317e1ab8feba2d95800309c1c15f2dee Mon Sep 17 00:00:00 2001 From: yzp Date: Tue, 25 Mar 2025 10:04:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E8=AE=BE=E7=BD=AE=E7=9A=84key?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E6=8A=8A=E6=95=B4=E4=B8=AAkey=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E6=96=87=E6=9C=AC=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/src/i18n/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Web/src/i18n/index.ts b/Web/src/i18n/index.ts index 32eea183..674dc5ec 100644 --- a/Web/src/i18n/index.ts +++ b/Web/src/i18n/index.ts @@ -167,6 +167,12 @@ export const i18n = createI18n({ fallbackLocale: 'zh-CN', messages, globalInjection: true, + fallbackFormat: false, // 关闭默认的 fallback 行为 + missing: (locale, key) => { + // 安全地获取最后一部分,如果没有'.'则返回整个key + const lastPart = key.includes('.') ? key.split('.').pop()! : key; + return lastPart.replace(/\${(.+?)}/g, '$1'); + } }); //iso 3166-1 国家代码