Skip to content

Commit 4d7e99c

Browse files
Add zh-TW locale
1 parent e4fea6c commit 4d7e99c

2 files changed

Lines changed: 70 additions & 9 deletions

File tree

src/i18n/index.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,34 @@ import es from './es.json'
55
import zh from './zh.json'
66
import pt from './pt.json'
77
import fr from './fr.json'
8+
import zhTW from './zh-TW.json'
89

910
Vue.use(VueI18n)
1011

11-
const locale = window.navigator.language ? window.navigator.language.substring(0, 2) : "en";
12+
const messages = {
13+
'en': en,
14+
'es': es,
15+
'zh': zh,
16+
'pt': pt,
17+
'fr': fr,
18+
'zh-TW': zhTW,
19+
};
20+
21+
const locale = (() => {
22+
const locales = Object.keys(messages);
23+
const navLang = window.navigator.language;
24+
const navLangShort = navLang.slice(0, 2);
25+
26+
if (!navLang) { return 'en'; }
27+
if (locales.includes(navLang)) { return navLang; }
28+
if (locales.includes(navLangShort)) { return navLangShort; }
29+
return 'en';
30+
})();
1231

1332
export function createI18n () {
1433
return new VueI18n({
1534
locale: locale,
1635
fallbackLocale: 'en',
17-
messages: {
18-
'en': en,
19-
'es': es,
20-
'zh': zh,
21-
'pt': pt,
22-
'fr': fr
23-
}
24-
})
36+
messages,
37+
});
2538
};

src/i18n/zh-TW.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"header": {
3+
"builtby": "built with 🌮 by"
4+
},
5+
"form": {
6+
"columns": "直行",
7+
"rows": "橫列",
8+
"columngap": "直行間距",
9+
"rowgap": "橫列間距",
10+
"codebutton": "請給我範例中的程式碼",
11+
"project": "這個專案在做什麼?",
12+
"reset": "重設布局",
13+
"units": "(px)"
14+
},
15+
"modal": {
16+
"header": {
17+
"yourcode": "您的 Grid 程式碼",
18+
"what": "這是什麼?"
19+
},
20+
"copy": {
21+
"title": "複製以下程式碼:",
22+
"clipboard": "複製",
23+
"clipboardSuccess": "複製成功!",
24+
"html": "展示 HTML",
25+
"css": "展示 CSS"
26+
},
27+
"button": "完成"
28+
},
29+
"grid": {
30+
"realcssunit": "請使用正確的 CSS 單位"
31+
},
32+
"explain": {
33+
"paragraph1": "您可以設定行列的數量和單位,我將會為你生成該 CSS Grid 網格布局!<strong>拖曳方框</strong>可在網格內建立 div。",
34+
"paragraph2": "雖然本專案可以為您提供一個基本的布局,但不是對 CSS Grid 功能的全面介紹。這只是一種快速生成 CSS Grid 網格布局的方法。",
35+
"paragraph3": "我注意到很多人沒有使用網格布局,因為他們覺得太複雜了,難以理解。CSS Grid 可以做很多事情,而這個小生成器只涉及到了一小部分功能。 目的是讓大家能夠快速上手並建立更多有趣的布局。",
36+
"paragraph4": "一旦你對此有所了解,建議您可以通過以下資源:",
37+
"cssguide": "CSS Grid Guide on CSS-Tricks",
38+
"paragraph5": "進行更深入的了解。 還有一個",
39+
"paragraph6": "和一個有趣的小遊戲叫",
40+
"paragraph7": "可以幫助您了解更多!",
41+
"contributions": "這個項目是開源的!",
42+
"fork": "請在這裡 Fork",
43+
"note": "請注意:螢幕閱讀器將按照添加 div 的順序讀取 div,請在構建 Grid 網格布局時牢記這一點"
44+
},
45+
"utils": {
46+
"and": ""
47+
}
48+
}

0 commit comments

Comments
 (0)