edit html title for each lang
This commit is contained in:
parent
4c9a7ae41c
commit
072e7aa892
16
src/utils.ts
16
src/utils.ts
@ -10,7 +10,18 @@
|
||||
* 设置HTML文档的lang属性
|
||||
* @param locale - i18n的locale值 (例如 'zh_CN', 'en', 'ja' 等)
|
||||
*/
|
||||
export function setHtmlLang(locale: string): void {
|
||||
export const setHtmlLang = (locale: string) => {
|
||||
setHtmlLang_(locale, {
|
||||
'zh_CN': '5 大潜能测试',
|
||||
'zh_TW': '5 大潛能測試',
|
||||
'ja': `L'Oréal 5 Potential Self-test`,
|
||||
'ko': `L'Oréal 5 Potential Self-test`,
|
||||
'en': `L'Oréal 5 Potential Self-test`
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function setHtmlLang_(locale: string, title?: Record<string, string>): void {
|
||||
const langMap: Record<string, string> = {
|
||||
'zh_CN': 'zh-CN',
|
||||
'zh_TW': 'zh-TW',
|
||||
@ -19,6 +30,9 @@ export function setHtmlLang(locale: string): void {
|
||||
'en': 'en'
|
||||
};
|
||||
document.documentElement.lang = langMap[locale] || 'en';
|
||||
if (title) {
|
||||
document.title = title[locale] || title['en'] || 'Default Title';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user