Skip to content

Commit 5a29163

Browse files
committed
fix: timeline's timeAgo i18n support.
1 parent f68f899 commit 5a29163

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

resource/i18n/en.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "English (Beta)",
33
"code": "en",
44
"authors": [
5-
"ronggang", "ylxb2016", "xiongqiwei", "jackson008"
5+
"ronggang",
6+
"ylxb2016",
7+
"xiongqiwei",
8+
"jackson008",
9+
"MewX"
610
],
711
"words": {
812
"app": {
@@ -223,6 +227,16 @@
223227
"showSites": "Show Sites",
224228
"close": "Close",
225229
"shareMessage": "Growth process",
230+
"time": {
231+
"year": " year(s) ",
232+
"month": " month(s) ",
233+
"day": " day(s) ",
234+
"hour": " hour(s) ",
235+
"mins": " minute(s) ",
236+
"week": " week(s) ",
237+
"ago": " ago",
238+
"lessThanAWeek": "Less than a week"
239+
},
226240
"total": {
227241
"uploaded": "Total uploads: ",
228242
"downloaded": "Total download: ",

resource/i18n/zh-CN.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "简体中文 Chinese (Simplified)",
33
"code": "zh-CN",
44
"authors": [
5-
"栽培者"
5+
"栽培者",
6+
"MewX"
67
],
78
"words": {
89
"app": {
@@ -222,6 +223,16 @@
222223
"showSites": "展示站点",
223224
"close": "关闭",
224225
"shareMessage": "这些年走过的路",
226+
"time": {
227+
"year": "",
228+
"month": "",
229+
"day": "",
230+
"hour": "",
231+
"mins": "",
232+
"week": "",
233+
"ago": "",
234+
"lessThanAWeek": "不满一周"
235+
},
225236
"total": {
226237
"uploaded": "上传总量:",
227238
"downloaded": "下载总量:",

src/options/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class i18nService {
2626
public vuei18n = i18n;
2727

2828
constructor() {
29-
// 加载英文内容
29+
// 加载所有语言包
3030
this.loadLangResource("en");
3131
this.loadLangResource("zh-CN");
3232
}

src/options/main.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class Main {
2020
private loadCount = 0;
2121

2222
constructor() {
23-
this.initVueConfig();
2423
this.initI18n();
24+
this.initVueConfig();
2525
this.initMainVM();
2626
this.init();
2727
}
@@ -68,12 +68,12 @@ class Main {
6868
return "";
6969
}
7070
let unit = {
71-
year: "年",
72-
month: "月",
73-
day: "日",
74-
hour: "时",
75-
mins: "分",
76-
week: "周"
71+
year: this.i18n.vuei18n.t("timeline.time.year", this.i18n.currentLanguage).toString(),
72+
month: this.i18n.vuei18n.t("timeline.time.month", this.i18n.currentLanguage).toString(),
73+
day: this.i18n.vuei18n.t("timeline.time.day", this.i18n.currentLanguage).toString(),
74+
hour: this.i18n.vuei18n.t("timeline.time.hour", this.i18n.currentLanguage).toString(),
75+
mins: this.i18n.vuei18n.t("timeline.time.minute", this.i18n.currentLanguage).toString(),
76+
week: this.i18n.vuei18n.t("timeline.time.week", this.i18n.currentLanguage.toString())
7777
};
7878

7979
let now = new Date().getTime();
@@ -87,7 +87,7 @@ class Main {
8787
if (weekOnly) {
8888
let week = Math.floor(days / 7);
8989
if (week < 1) {
90-
return "不满一周";
90+
return this.i18n.vuei18n.t("timeline.time.lessThanAWeek", this.i18n.currentLanguage).toString();
9191
}
9292
return `${week}${unit.week}`;
9393
}
@@ -127,7 +127,7 @@ class Main {
127127
result = "< 1" + unit["mins"];
128128
}
129129

130-
return result + "前";
130+
return result + this.i18n.vuei18n.t("timeline.time.ago", this.i18n.currentLanguage).toString();
131131
});
132132
}
133133

0 commit comments

Comments
 (0)