[DEV-113] change ticket date according to selected language (#1086)

* fix apidoc

* update tickets date according selected language

* sync language abbreviations

* fix today/yesterday ticket date & hindi bug

* erase useless comments
This commit is contained in:
Guillermo Giuliana 2021-11-25 17:55:51 -03:00 committed by GitHub
parent f1d746f9f9
commit f5e9b2602c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 8 deletions

View File

@ -226,7 +226,7 @@ class TicketList extends React.Component {
}
getTableRows() {
return this.getTickets().map(this.gerTicketTableObject.bind(this));
return this.getTickets().map(this.getTicketTableObject.bind(this));
}
getTickets() {
@ -240,7 +240,7 @@ class TicketList extends React.Component {
);
}
gerTicketTableObject(ticket) {
getTicketTableObject(ticket) {
const { date, title, ticketNumber, closed, tags, department, author } = ticket;
const dateTodayWithOutHoursAndMinutes = DateTransformer.getDateToday();
const ticketDateWithOutHoursAndMinutes = Math.floor(DateTransformer.UTCDateToLocalNumericDate(JSON.stringify(date*1)) / 10000);
@ -248,7 +248,7 @@ class TicketList extends React.Component {
const ticketDate = (
((dateTodayWithOutHoursAndMinutes - ticketDateWithOutHoursAndMinutes) > 1) ?
stringTicketLocalDateFormat :
`${(dateTodayWithOutHoursAndMinutes - ticketDateWithOutHoursAndMinutes) ? "Yesterday" : "Today"} at ${stringTicketLocalDateFormat.slice(-5)}`
`${(dateTodayWithOutHoursAndMinutes - ticketDateWithOutHoursAndMinutes) ? i18n("YESTERDAY_AT") : i18n("TODAY_AT")} ${stringTicketLocalDateFormat.slice(-5)}`
);
let titleText = (this.isTicketUnread(ticket)) ? title + ' (1)' : title;

View File

@ -445,6 +445,8 @@ export default {
'TITLE_EDITED': '(title edited)',
'COMMENT_EDITED': '(comment edited)',
'TODAY_AT': 'Today at',
'YESTERDAY_AT': 'Yesterday at',
'LAST_7_DAYS': 'Last 7 days',
'LAST_30_DAYS': 'Last 30 days',
'LAST_90_DAYS': 'Last 90 days',

View File

@ -1,7 +1,14 @@
import moment from 'moment';
import sessionStore from 'lib-app/session-store';
const stringDateFormat = 'YYYYMMDDHHmm';
const localUTCMins = new Date().getTimezoneOffset();
let language = sessionStore.getConfigs().language;
if (language == 'br') language = 'pt';
if (language == 'cn') language = 'zh-cn';
if (language == 'in') language = 'hi';
if (language == 'jp') language = 'ja';
if (language == 'gr') language = 'el';
export default {
stringDateToMoment(date) {
@ -26,9 +33,9 @@ export default {
},
transformToString(date, expressive = true, retrunShortcutDate = false) {
const momentDateLocal = this.stringDateToMoment(JSON.stringify(this.UTCDateToLocalNumericDate(date)));
if(expressive) momentDateLocal.format('D MMMM YYYY');
if(retrunShortcutDate) return momentDateLocal.format('D MMM YYYY, HH:mm');
return momentDateLocal.format('D MMMM YYYY, HH:mm');
if(expressive) momentDateLocal.locale(language).format('D MMMM YYYY');
if(retrunShortcutDate) return momentDateLocal.locale(language).format('D MMM YYYY, HH:mm');
return momentDateLocal.locale(language).format('D MMMM YYYY, HH:mm');
},
getDate(date) {
return date < 10 ? `0${date}` : `${date}`;

View File

@ -12,11 +12,11 @@ class Language extends DataStore {
'jp',
'ru',
'cn',
'in',
'in',
'tr',
'it',
'br',
'gr',
'gr',
'nl',
'pl'
];