未设置的key不要把整个key作为文本输出

This commit is contained in:
yzp 2025-03-25 10:04:22 +08:00
parent 03b0eeec58
commit e8fca09431

View File

@ -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 国家代码