feat(i18n.ts): 国际化i18n工具类和动态路由国际化的方法generateTitle

This commit is contained in:
郝先瑞
2022-02-24 00:00:57 +08:00
parent dedd7f2c46
commit 7cb45d05a0

12
src/utils/i18n.ts Normal file
View File

@@ -0,0 +1,12 @@
// translate router.meta.title, be used in breadcrumb sidebar tagsview
import i18n from "@/lang/index";
export function generateTitle(title: any) {
// 判断是否存在国际化配置,如果没有原生返回
const hasKey = i18n.global.te('route.' + title)
if (hasKey) {
const translatedTitle = i18n.global.t('route.' + title)
return translatedTitle
}
return title
}