2023-04-02 01:01:56 +08:00
|
|
|
|
// translate router.meta.title, be used in breadcrumb sidebar tagsview
|
|
|
|
|
import i18n from '@/lang/index';
|
|
|
|
|
|
2023-04-19 11:05:30 +08:00
|
|
|
|
/**
|
|
|
|
|
* 获取国际化路由,如果不存在则原生返回
|
|
|
|
|
* @param title 路由名称
|
|
|
|
|
* @returns {string}
|
|
|
|
|
*/
|
|
|
|
|
export const translateRouteTitle = (title: string): string => {
|
2023-04-03 00:05:09 +08:00
|
|
|
|
const hasKey = i18n.global.te('route.' + title);
|
|
|
|
|
if (hasKey) {
|
|
|
|
|
const translatedTitle = i18n.global.t('route.' + title);
|
|
|
|
|
return translatedTitle;
|
|
|
|
|
}
|
|
|
|
|
return title;
|
2023-04-02 01:01:56 +08:00
|
|
|
|
};
|