未设置的key不要把整个key作为文本输出
This commit is contained in:
parent
03b0eeec58
commit
e8fca09431
@ -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 国家代码
|
||||
|
||||
Loading…
Reference in New Issue
Block a user