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'
|
||||
this.availableJsonTranslation= LocalesArr[LocalesArr.findIndex(locale => locale.includes(lang))];
|
||||
|
||||
if (this.$i18n.messages[this.browserLanguage]) {
|
||||
this.$store.commit("setLanguage", this.browserLanguage);
|
||||
} else if (this.browserLanguage.includes("-")) {
|
||||
if (this.$i18n.messages[lang]) {
|
||||
this.$store.commit("setLanguage", lang);
|
||||
if (!this.$store.state.language) {
|
||||
// Set default language if not set already
|
||||
if (this.$i18n.messages[this.browserLanguage]) {
|
||||
this.$store.commit("setLanguage", this.browserLanguage);
|
||||
} else if (this.browserLanguage.includes("-")) {
|
||||
if (this.$i18n.messages[lang]) {
|
||||
this.$store.commit("setLanguage", lang);
|
||||
} else {
|
||||
this.$store.commit("setLanguage", this.availableJsonTranslation);
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("setLanguage", this.availableJsonTranslation);
|
||||
}
|
||||
} else {
|
||||
this.$store.commit("setLanguage", this.availableJsonTranslation);
|
||||
}
|
||||
|
||||
// Set language
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@
|
|||
"user_changed_guest_access_open": "{user} allowed guests to join the room",
|
||||
"reply_image": "Image",
|
||||
"reply_audio_message": "Audio message",
|
||||
"reply_video": "Video"
|
||||
"reply_video": "Video",
|
||||
"time_ago": "Today | Yesterday | {count} days ago"
|
||||
},
|
||||
"room": {
|
||||
"invitations": "You have no invitations | You have 1 invitation | You have {count} invitations",
|
||||
|
|
|
|||
|
|
@ -1738,7 +1738,12 @@ export default {
|
|||
},
|
||||
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -546,19 +546,15 @@ class Util {
|
|||
return t2.diff(t1, 'day');
|
||||
}
|
||||
|
||||
formatDay(timestamp) {
|
||||
dayDiffToday(timestamp) {
|
||||
var then = dayjs(timestamp).endOf('day');
|
||||
var now = dayjs().endOf('day');
|
||||
const dayDiff = now.diff(then, 'day');
|
||||
if (dayDiff < 1) {
|
||||
return "Today";
|
||||
} else if (dayDiff < 2) {
|
||||
return "Yesterday";
|
||||
} else if (dayDiff < 7) {
|
||||
return "" + dayDiff + " days ago";
|
||||
} else {
|
||||
return then.format('L');
|
||||
}
|
||||
return now.diff(then, 'day');
|
||||
}
|
||||
|
||||
formatDay(timestamp) {
|
||||
var then = dayjs(timestamp).endOf('day');
|
||||
return then.format('L');
|
||||
}
|
||||
|
||||
formatRecordDuration(ms) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue