Skip to content

Commit

Permalink
fix: timeline's timeAgo i18n support.
Browse files Browse the repository at this point in the history
  • Loading branch information
MewX committed Feb 22, 2022
1 parent f68f899 commit 5a29163
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
16 changes: 15 additions & 1 deletion resource/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"name": "English (Beta)",
"code": "en",
"authors": [
"ronggang", "ylxb2016", "xiongqiwei", "jackson008"
"ronggang",
"ylxb2016",
"xiongqiwei",
"jackson008",
"MewX"
],
"words": {
"app": {
Expand Down Expand Up @@ -223,6 +227,16 @@
"showSites": "Show Sites",
"close": "Close",
"shareMessage": "Growth process",
"time": {
"year": " year(s) ",
"month": " month(s) ",
"day": " day(s) ",
"hour": " hour(s) ",
"mins": " minute(s) ",
"week": " week(s) ",
"ago": " ago",
"lessThanAWeek": "Less than a week"
},
"total": {
"uploaded": "Total uploads: ",
"downloaded": "Total download: ",
Expand Down
13 changes: 12 additions & 1 deletion resource/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "简体中文 Chinese (Simplified)",
"code": "zh-CN",
"authors": [
"栽培者"
"栽培者",
"MewX"
],
"words": {
"app": {
Expand Down Expand Up @@ -222,6 +223,16 @@
"showSites": "展示站点",
"close": "关闭",
"shareMessage": "这些年走过的路",
"time": {
"year": "",
"month": "",
"day": "",
"hour": "",
"mins": "",
"week": "",
"ago": "",
"lessThanAWeek": "不满一周"
},
"total": {
"uploaded": "上传总量:",
"downloaded": "下载总量:",
Expand Down
2 changes: 1 addition & 1 deletion src/options/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class i18nService {
public vuei18n = i18n;

constructor() {
// 加载英文内容
// 加载所有语言包
this.loadLangResource("en");
this.loadLangResource("zh-CN");
}
Expand Down
18 changes: 9 additions & 9 deletions src/options/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Main {
private loadCount = 0;

constructor() {
this.initVueConfig();
this.initI18n();
this.initVueConfig();
this.initMainVM();
this.init();
}
Expand Down Expand Up @@ -68,12 +68,12 @@ class Main {
return "";
}
let unit = {
year: "年",
month: "月",
day: "日",
hour: "时",
mins: "分",
week: "周"
year: this.i18n.vuei18n.t("timeline.time.year", this.i18n.currentLanguage).toString(),
month: this.i18n.vuei18n.t("timeline.time.month", this.i18n.currentLanguage).toString(),
day: this.i18n.vuei18n.t("timeline.time.day", this.i18n.currentLanguage).toString(),
hour: this.i18n.vuei18n.t("timeline.time.hour", this.i18n.currentLanguage).toString(),
mins: this.i18n.vuei18n.t("timeline.time.minute", this.i18n.currentLanguage).toString(),
week: this.i18n.vuei18n.t("timeline.time.week", this.i18n.currentLanguage.toString())
};

let now = new Date().getTime();
Expand All @@ -87,7 +87,7 @@ class Main {
if (weekOnly) {
let week = Math.floor(days / 7);
if (week < 1) {
return "不满一周";
return this.i18n.vuei18n.t("timeline.time.lessThanAWeek", this.i18n.currentLanguage).toString();
}
return `${week}${unit.week}`;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ class Main {
result = "< 1" + unit["mins"];
}

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

Expand Down

0 comments on commit 5a29163

Please sign in to comment.