Skip to content

Commit 9523a69

Browse files
authored
feat: add i18n(zh-tw) support (and rename 'zh' as 'zh-CN') (#290)
1 parent bd0730b commit 9523a69

File tree

6 files changed

+242
-5
lines changed

6 files changed

+242
-5
lines changed

client/i18next-parser.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default {
4747
lineEnding: 'auto',
4848
// Control the line ending. See options at https://github.com/ryanve/eol
4949

50-
locales: ['en', 'zh', 'ja'],
50+
locales: ['en', 'zh-CN', 'zh-TW', 'ja'],
5151
// An array of the locales in your applications
5252

5353
namespaceSeparator: ':',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
{
2+
"about": {
3+
"notfound": "將文章別名設定為 about 可以創建關於頁面",
4+
"title": "關於"
5+
},
6+
"alert": "提示",
7+
"alias": "別名",
8+
"article": {
9+
"delete": {
10+
"confirm": "確定刪除這篇文章嗎?",
11+
"title": "刪除文章"
12+
},
13+
"search": {
14+
"placeholder": "請輸入關鍵字",
15+
"title": "搜尋",
16+
"title$keyword": "搜尋:{{keyword}}"
17+
},
18+
"title": "文章",
19+
"top": {
20+
"confirm": "確定置頂這篇文章嗎?",
21+
"success": "置頂成功",
22+
"title": "置頂"
23+
},
24+
"total_short$count_one": "{{count}} 篇",
25+
"total_short$count_other": "{{count}} 篇",
26+
"total$count_one": "共有 {{count}} 篇文章",
27+
"total$count_other": "共有 {{count}} 篇文章",
28+
"untop": {
29+
"confirm": "確定取消置頂這篇文章嗎?",
30+
"success": "取消置頂成功",
31+
"title": "取消置頂"
32+
}
33+
},
34+
"avatar": {
35+
"url": "頭像 URL"
36+
},
37+
"cancel": "取消",
38+
"clear": "清除",
39+
"close": "關閉",
40+
"comment": {
41+
"empty": "留言内容不能為空",
42+
"placeholder": {
43+
"title": "說點什麼吧"
44+
},
45+
"submit": "發表留言",
46+
"success": "留言成功",
47+
"title": "留言"
48+
},
49+
"comparison": "比較",
50+
"confirm": "確認",
51+
"content": {
52+
"empty": "内容不能為空"
53+
},
54+
"count": {
55+
"pv": "瀏覽數",
56+
"uv": "訪客數"
57+
},
58+
"create": {
59+
"success": "創建成功",
60+
"title": "創建"
61+
},
62+
"created_at": "發布時間",
63+
"delete": {
64+
"comment": {
65+
"confirm": "確定要刪除這則留言嗎?",
66+
"title": "刪除留言"
67+
},
68+
"confirm": "確定要刪除嗎?",
69+
"success": "刪除成功",
70+
"title": "刪除"
71+
},
72+
"description": "描述",
73+
"draft": "草稿",
74+
"draft_bin": "草稿箱",
75+
"edit": "編輯",
76+
"error": {
77+
"api_url": "Pages 環境變數中 API_URL 應為 Worker 地址,請檢查 Pages 環境變數中 API_URL 是否正確",
78+
"api_url_slash": "Pages 環境變數中 API_URL 應為 Worker 地址,請檢查 Pages 環境變數中 API_URL 是否正確,且 API_URL 末尾不能有 /",
79+
"github_callback": "GitHub OAuth 回調地址應為 `https://<Worker 地址>/user/github/callback,請檢查 GitHub OAuth 回調地址是否正確"
80+
},
81+
"feed_card": {
82+
"published$time": "{{time}} 發布",
83+
"updated$time": "{{time}} 更新"
84+
},
85+
"footer": {
86+
"rss": "RSS 訂閱連結"
87+
},
88+
"friends": {
89+
"apply": "申請友情連結",
90+
"create": "創建友情連結",
91+
"left": "暫時離開",
92+
"my_apply": "我的申請",
93+
"review": {
94+
"accepted": "接受",
95+
"rejected": "拒絕",
96+
"waiting": "待審核"
97+
},
98+
"title": "朋友們"
99+
},
100+
"github_login": "Github 登入",
101+
"hashtags": "標籤",
102+
"home": "首頁",
103+
"index": {
104+
"back": "返回首頁",
105+
"empty": {
106+
"title": "目錄為空"
107+
},
108+
"title": "目錄"
109+
},
110+
"listed": "列出在文章中",
111+
"login": {
112+
"oauth_only": "請登入後繼續",
113+
"password": {
114+
"placeholder": "請輸入密碼"
115+
},
116+
"required": "請登入後繼續",
117+
"title": "登入",
118+
"username": {
119+
"placeholder": "請輸入用戶名"
120+
}
121+
},
122+
"logout": "登出",
123+
"next": "下一頁",
124+
"preview": "預覽",
125+
"previous": "上一頁",
126+
"publish": {
127+
"success": "發布成功",
128+
"title": "發布"
129+
},
130+
"reload": "重試",
131+
"save": "保存",
132+
"settings": {
133+
"cache": {
134+
"clear": {
135+
"confirm": {
136+
"desc": "緩存用於減少訪問資料庫頻率,請僅在緩存錯誤時嘗試清空緩存。",
137+
"title": "確認清空緩存嗎?"
138+
},
139+
"desc": "清除所有緩存文件",
140+
"title": "清除緩存"
141+
},
142+
"clear_failed$message": "清除緩存失敗: {{message}}"
143+
},
144+
"comment": {
145+
"enable": {
146+
"desc": "開啟/關閉文章底部留言入口與留言區",
147+
"title": "啟用留言"
148+
}
149+
},
150+
"counter": {
151+
"enable": {
152+
"desc": "啟用統計文章 PV 與 UV 功能",
153+
"title": "啟用訪問量統計"
154+
}
155+
},
156+
"favicon": {
157+
"desc": "設定顯示於瀏覽器的地址欄的圖標(Favicon)",
158+
"title": "網站圖標"
159+
},
160+
"footer": {
161+
"desc": "設定顯示於網站底部的内容(HTML)",
162+
"title": "網站底部内容"
163+
},
164+
"friend": {
165+
"apply": {
166+
"desc": "允許其他用戶申請友情連結(需審核)",
167+
"title": "友情連結申請"
168+
},
169+
"health": {
170+
"desc": "啟用朋友們連結可訪問性檢查",
171+
"title": "友情連結健康監測",
172+
"ua": {
173+
"desc": "設定友情連結可訪問性檢查時使用的 User-Agent, 預設 'Rin-Check/1.0'",
174+
"title": "友情連結健康監測 User-Agent"
175+
}
176+
},
177+
"title": "友情連結設定"
178+
},
179+
"get_config_failed$message": "獲取配置失敗,{{message}}",
180+
"import_failed$message": "匯入失敗,{{message}}",
181+
"import_result": "匯入结果",
182+
"import_skipped": "跳過匯入",
183+
"import_skipped_item$title$reason": "《{{title}}》- {{reason}}",
184+
"import_success$success$skipped": "匯入成功,{{success}} 篇文章匯入成功,{{skipped}} 篇文章跳過",
185+
"login": {
186+
"enable": {
187+
"desc": "開啟/關閉右上角登入按钮,關閉後可通過「雙擊」底部文字 “© 2024 Powered by” 「三次」觸發登入入口",
188+
"title": "啟用右上角登入按钮"
189+
}
190+
},
191+
"other": {
192+
"title": "其他設定"
193+
},
194+
"rss": {
195+
"desc": "啟用網站底部 RSS 訂閱連結",
196+
"title": "RSS 訂閱連結"
197+
},
198+
"title": "設定",
199+
"update_failed$message": "更新失敗: {{message}}",
200+
"wordpress": {
201+
"desc": "上傳 WordPress 匯出的 XML 文件",
202+
"title": "從 WordPress 匯入"
203+
}
204+
},
205+
"sitename": "網站名稱",
206+
"status": "狀態",
207+
"summary": "簡介",
208+
"tags": "標籤",
209+
"timeline": "時間軸",
210+
"title": "標題",
211+
"title_empty": "標題不能為空",
212+
"top": {
213+
"title": "置頂"
214+
},
215+
"unlisted": "未列出",
216+
"untitled": "未列出",
217+
"untop": {
218+
"title": "取消置頂"
219+
},
220+
"update": {
221+
"success": "更新成功",
222+
"title": "更新"
223+
},
224+
"update$sth": "更新 {{sth}}",
225+
"upload": {
226+
"failed": "上傳失敗",
227+
"failed$size": "上傳失敗,文件大小不能超過 {{size}} MB",
228+
"title": "上傳"
229+
},
230+
"uploading": "上傳中",
231+
"url": "網站 URL",
232+
"visible": {
233+
"self_only": "僅自己可見"
234+
},
235+
"writing": "寫作",
236+
"year$year": "{{year}} 年"
237+
}

client/src/components/header.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ function LanguageSwitch({ className }: { className?: string }) {
161161
const label = 'Languages'
162162
const languages = [
163163
{ code: 'en', name: 'English' },
164-
{ code: 'zh', name: '简体中文' },
164+
{ code: 'zh-CN', name: '简体中文' },
165+
{ code: 'zh-TW', name: '繁體中文' },
165166
{ code: 'ja', name: '日本語' }
166167
]
167168
return (

client/src/main.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ i18n
2828
// the translations
2929
// (tip move them in a JSON file and import them,
3030
// or even better, manage them via a UI: https://react.i18next.com/guides/multiple-translation-files#manage-your-translations-with-a-management-gui)
31-
load: 'languageOnly',
3231
fallbackLng: "en",
3332
interpolation: {
3433
escapeValue: false // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape

client/src/utils/timeago.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { format } from "@astroimg/timeago";
2-
import i18n from "i18next"
2+
import i18n from "i18next";
33

44
export function timeago(time: string | number | Date) {
5-
const locale = i18n.language !== 'zh' ? 'en' : 'zh-CN'
5+
const locale = i18n.language !== 'zh-CN' ? 'en' : 'zh-CN'
66
return format(time, "DEFAULT", locale)
77
}

0 commit comments

Comments
 (0)