Skip to content

Commit

Permalink
updated title
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Apr 18, 2022
1 parent 9be6ecd commit cbd3df1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/i18n/lang/en/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const global: LGlobal = {
pro: 'Pro',
enterprise: 'Enterprise',
},
title: 'Crawlab | Distributed Web Crawler Platform',
title: 'Crawlab',
subTitle: 'Distributed Web Crawler Platform',
};

export default global;
3 changes: 2 additions & 1 deletion src/i18n/lang/zh/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const global: LGlobal = {
pro: '专业版',
enterprise: '企业版',
},
title: 'Crawlab | 分布式爬虫管理平台',
title: 'Crawlab',
subTitle: '分布式爬虫管理平台',
};

export default global;
1 change: 1 addition & 0 deletions src/interfaces/i18n/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export declare global {
enterprise: string;
};
title: string;
subTitle: string;
}
}
14 changes: 9 additions & 5 deletions src/utils/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import {getI18n} from '@/i18n';
import {updateTitle} from '@/utils/dom';
import {LOCAL_STORAGE_KEY_LANG} from '@/constants/localStorage';
import {getStore} from '@/store';

export const translate = (path: string, args?: any): string => {
const {t} = getI18n().global;
const i18n = getI18n();
const global = i18n.global;
const {t} = global;
const res = args !== undefined ? t(path, args) : t(path);
if (typeof res === 'string') return res;
return path;
};
window._t = translate;

export const translateC = (c: number, path: string): string => {
const {n} = getI18n().global;
const i18n = getI18n();
const global = i18n.global;
const {n} = global;
const res = n(c, path);
console.debug(res, c, path);
if (typeof res === 'string') return res;
return path;
};
Expand All @@ -33,7 +35,9 @@ export const setGlobalLang = (lang: Lang) => {
getI18n().global.locale.value = lang;

// update title
updateTitle(translate('global.title'));
const title = translate('global.title');
const subTitle = translate('global.subTitle');
updateTitle(`${title} | ${subTitle}`);
};

export const getLanguage = (): string => {
Expand Down

0 comments on commit cbd3df1

Please sign in to comment.