Add translation keys for "today", "yesterday" and "x days ago".
This commit is contained in:
parent
d39f260261
commit
5d05dfd019
4 changed files with 25 additions and 20 deletions
17
src/App.vue
17
src/App.vue
|
|
@ -87,16 +87,19 @@ export default {
|
||||||
// Assigns available language for ex 'zh_Hans' when browser header language is 'zh' or 'zh-HK'
|
// Assigns available language for ex 'zh_Hans' when browser header language is 'zh' or 'zh-HK'
|
||||||
this.availableJsonTranslation= LocalesArr[LocalesArr.findIndex(locale => locale.includes(lang))];
|
this.availableJsonTranslation= LocalesArr[LocalesArr.findIndex(locale => locale.includes(lang))];
|
||||||
|
|
||||||
if (this.$i18n.messages[this.browserLanguage]) {
|
if (!this.$store.state.language) {
|
||||||
this.$store.commit("setLanguage", this.browserLanguage);
|
// Set default language if not set already
|
||||||
} else if (this.browserLanguage.includes("-")) {
|
if (this.$i18n.messages[this.browserLanguage]) {
|
||||||
if (this.$i18n.messages[lang]) {
|
this.$store.commit("setLanguage", this.browserLanguage);
|
||||||
this.$store.commit("setLanguage", lang);
|
} else if (this.browserLanguage.includes("-")) {
|
||||||
|
if (this.$i18n.messages[lang]) {
|
||||||
|
this.$store.commit("setLanguage", lang);
|
||||||
|
} else {
|
||||||
|
this.$store.commit("setLanguage", this.availableJsonTranslation);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$store.commit("setLanguage", this.availableJsonTranslation);
|
this.$store.commit("setLanguage", this.availableJsonTranslation);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.$store.commit("setLanguage", this.availableJsonTranslation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set language
|
// Set language
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,8 @@
|
||||||
"user_changed_guest_access_open": "{user} allowed guests to join the room",
|
"user_changed_guest_access_open": "{user} allowed guests to join the room",
|
||||||
"reply_image": "Image",
|
"reply_image": "Image",
|
||||||
"reply_audio_message": "Audio message",
|
"reply_audio_message": "Audio message",
|
||||||
"reply_video": "Video"
|
"reply_video": "Video",
|
||||||
|
"time_ago": "Today | Yesterday | {count} days ago"
|
||||||
},
|
},
|
||||||
"room": {
|
"room": {
|
||||||
"invitations": "You have no invitations | You have 1 invitation | You have {count} invitations",
|
"invitations": "You have no invitations | You have 1 invitation | You have {count} invitations",
|
||||||
|
|
|
||||||
|
|
@ -1738,7 +1738,12 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
dayForEvent(event) {
|
dayForEvent(event) {
|
||||||
return util.formatDay(event.getTs());
|
let dayDiff = util.dayDiffToday(event.getTs());
|
||||||
|
if (dayDiff < 7) {
|
||||||
|
return this.$tc("message.time_ago", dayDiff);
|
||||||
|
} else {
|
||||||
|
return util.formatDay(event.getTs());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showRecordingUI() {
|
showRecordingUI() {
|
||||||
|
|
|
||||||
|
|
@ -546,19 +546,15 @@ class Util {
|
||||||
return t2.diff(t1, 'day');
|
return t2.diff(t1, 'day');
|
||||||
}
|
}
|
||||||
|
|
||||||
formatDay(timestamp) {
|
dayDiffToday(timestamp) {
|
||||||
var then = dayjs(timestamp).endOf('day');
|
var then = dayjs(timestamp).endOf('day');
|
||||||
var now = dayjs().endOf('day');
|
var now = dayjs().endOf('day');
|
||||||
const dayDiff = now.diff(then, 'day');
|
return now.diff(then, 'day');
|
||||||
if (dayDiff < 1) {
|
}
|
||||||
return "Today";
|
|
||||||
} else if (dayDiff < 2) {
|
formatDay(timestamp) {
|
||||||
return "Yesterday";
|
var then = dayjs(timestamp).endOf('day');
|
||||||
} else if (dayDiff < 7) {
|
return then.format('L');
|
||||||
return "" + dayDiff + " days ago";
|
|
||||||
} else {
|
|
||||||
return then.format('L');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formatRecordDuration(ms) {
|
formatRecordDuration(ms) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue