Skip to content

Commit

Permalink
Merge pull request #4316 from aman-atg/aman-atg-fix-spanishTrans
Browse files Browse the repository at this point in the history
Show time and date in the preferred locale
  • Loading branch information
jasperhuangg authored Jul 30, 2021
2 parents 5988631 + cffa51a commit 2444fdd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export default {
send: 'Send',
notifications: 'Notifications',
noResultsFound: 'No results found',
timePrefix: 'It\'s',
conjunctionFor: 'for',
todayAt: 'Today at',
tomorrowAt: 'Tomorrow at',
yesterdayAt: 'Yesterday at',
conjunctionAt: 'at',
},
attachmentPicker: {
cameraPermissionRequired: 'Camera Permission Required',
Expand Down
6 changes: 6 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export default {
send: 'Enviar',
notifications: 'Notificaciones',
noResultsFound: 'No se han encontrado resultados',
timePrefix: 'Son las',
conjunctionFor: 'para',
todayAt: 'Hoy a las',
tomorrowAt: 'Mañana a las',
yesterdayAt: 'Ayer a las',
conjunctionAt: 'a',
},
attachmentPicker: {
cameraPermissionRequired: 'Se necesita permiso para usar la cámara',
Expand Down
18 changes: 12 additions & 6 deletions src/libs/DateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import _ from 'underscore';
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
import {translate} from './translate';

let timezone;
Onyx.connect({
Expand Down Expand Up @@ -57,13 +58,18 @@ function timestampToDateTime(locale, timestamp, includeTimeZone = false) {
const date = getLocalMomentFromTimestamp(locale, timestamp);
const tz = includeTimeZone ? ' [UTC]Z' : '';

const todayAt = translate(locale, 'common.todayAt');
const tomorrowAt = translate(locale, 'common.tomorrowAt');
const yesterdayAt = translate(locale, 'common.yesterdayAt');
const at = translate(locale, 'common.conjunctionAt');

return moment(date).calendar({
sameDay: `[Today at] LT${tz}`,
nextDay: `[Tomorrow at] LT${tz}`,
nextWeek: `MMM D [at] LT${tz}`,
lastDay: `[Yesterday at] LT${tz}`,
lastWeek: `MMM D [at] LT${tz}`,
sameElse: `MMM D, YYYY [at] LT${tz}`,
sameDay: `[${todayAt}] LT${tz}`,
nextDay: `[${tomorrowAt}] LT${tz}`,
lastDay: `[${yesterdayAt}] LT${tz}`,
nextWeek: `MMM D [${at}] LT${tz}`,
lastWeek: `MMM D [${at}] LT${tz}`,
sameElse: `MMM D, YYYY [${at}] LT${tz}`,
});
}

Expand Down

0 comments on commit 2444fdd

Please sign in to comment.