fix: 国际化兜底处理 (#5877)

This commit is contained in:
qinhaoyan 2022-12-05 21:10:52 +08:00 committed by GitHub
parent 5c98f8a97b
commit 717e01fb07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,8 +51,12 @@ export function makeTranslator(locale?: string): TranslateFn {
return str;
}
const dict = locales[locale!] || locales[defaultLocale] || locales['zh-CN'];
return format(dict?.[str] || str, ...args);
const value =
locales[locale!]?.[str] ||
locales[defaultLocale]?.[str] ||
locales['zh-CN']?.[str] ||
str;
return format(value, ...args);
};
locale && (fns[locale] = fn);