You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
house/fount/utils/i18n.js

13 lines
773 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// translate router.meta.title, be used in breadcrumb sidebar tagsview // 用于翻译路由的 meta.title适用于面包屑、侧边栏和标签视图
export function generateTitle(title) { // 导出生成标题的函数,参数为标题名称
const hasKey = this.$te('route.' + title); // 检查是否存在对应的语言键值,$te 方法来自 vue-i18n
if (hasKey) { // 如果存在对应的键值
// $t :this method from vue-i18n, inject in @/lang/index.js // $t 方法来自 vue-i18n在 @/lang/index.js 中注入
const translatedTitle = this.$t('route.' + title); // 使用 $t 方法获取翻译后的标题
return translatedTitle; // 返回翻译后的标题
}
return title; // 如果没有找到对应的键值,返回原始标题
}