Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Localize Date and Time translations using AM/PM #5748

Merged
merged 23 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/admin/messages/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ get columns() {
isSortable : true,
cellComponent : 'ui-table/cell/cell-simple-date',
options : {
dateFormat: 'MMMM DD, YYYY - HH:mm A'
dateFormat: 'D MMM, YYYY h:mm A'
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/sessions/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
isSortable : true,
headerComponent : 'tables/headers/sort',
options : {
dateFormat: 'MMMM DD, YYYY - hh:mm A'
dateFormat: 'D MMM, YYYY h:mm A'
}
},
{
Expand Down
13 changes: 12 additions & 1 deletion app/helpers/general-date.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import Helper from '@ember/component/helper';
import moment from 'moment';

const locales12Hours = new Set(['en', 'bn', 'hi', 'id', 'ja', 'run', 'th', 'vi', 'ko']);

export function generalDate(params) {
const timezone = params[1] || moment.tz.guess();
const format = params[2] || 'h:mm A, MMMM Do YYYY (z)';

const local = moment(params[0]).tz(timezone).locale();

let format = params[2] || 'h:mm A, MMMM Do YYYY (z)';

if (!locales12Hours.has(local)) {
format = format.replaceAll('h', 'H');
format = format.replace(' A', '');
format = format.replace(' a', '');
}
return moment(params[0]).tz(timezone).format(format);
}

Expand Down
9 changes: 0 additions & 9 deletions app/helpers/header-date.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/templates/admin/sales/revenue.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{{order.name}}
</td>
<td>
{{moment-format order.eventDate 'D MMM, YYYY'}}
{{general-date order.eventDate '' 'D MMM, YYYY'}}
</td>
<td class="right aligned">
{{order.ticketCount}}
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/event-invoice/event-info.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<div class="ui padded segment">
<strong>{{t 'At'}} {{this.event.locationName}}</strong>
<br>
<strong>{{t 'From'}}:</strong> {{header-date this.event.startsAt}}
<strong>{{t 'From'}}:</strong> {{general-date this.event.startsAt}}
divyamtayal marked this conversation as resolved.
Show resolved Hide resolved
<br>
<strong>{{t 'To'}}:</strong> {{header-date this.event.endsAt}}
<strong>{{t 'To'}}:</strong> {{general-date this.event.endsAt}}
{{#if this.event.ownerName}}
<br>
<strong>{{t 'Organized By'}}:</strong> {{this.event.ownerName}}
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/event-invoice/invoice-summary.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<tbody>
<tr>
<td>{{this.event.name}}</td>
<td>{{moment-format this.data.issuedAt 'D MMM, YYYY'}}</td>
<td>{{moment-format this.data.completedAt 'D MMM, YYYY'}}</td>
<td>{{general-date this.data.issuedAt '' 'D MMM, YYYY'}}</td>
<td>{{general-date this.data.completedAt '' 'D MMM, YYYY'}}</td>
<td>{{currency-symbol this.eventCurrency}} {{format-money this.data.amount}}</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/footer-main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<div class="ui stackable grid">
<div class="thirteen wide computer twelve wide tablet column left aligned">
<div class="ui horizontal inverted small divided link list no top margin">
<span class="item">{{t 'Copyright'}} &copy; {{moment-format (now) 'YYYY'}} {{this.settings.appName}} </span>
<span class="item">{{t 'Copyright'}} &copy; {{general-date (now) '' 'YYYY'}} {{this.settings.appName}} </span>
<span class="hidden-item">
{{!-- Possible Page Values --}}
{{t 'Terms'}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/order-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</span>
<span>#{{this.order.identifier}}</span>
{{#if this.order.completedAt}}
<span>{{t 'on'}} {{moment-format this.order.completedAt 'MMMM DD, YYYY h:mm A'}}</span>
<span>{{t 'on'}} {{general-date this.order.completedAt '' 'D MMM, YYYY h:mm A'}}</span>
{{/if}}
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/orders/event-info.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
<strong>{{t 'Location or online event details to be announced'}}</strong>
{{/if}}
<br>
<strong>{{t 'From'}}:</strong> {{header-date this.data.event.startsAt}}
<strong>{{t 'From'}}:</strong> {{general-date this.data.event.startsAt}}
<br>
<strong>{{t 'To'}}:</strong> {{header-date this.data.event.endsAt}}
<strong>{{t 'To'}}:</strong> {{general-date this.data.event.endsAt}}
{{#if this.data.event.ownerName}}
<br>
<strong>{{t 'Organized By'}}:</strong> {{this.data.event.ownerName}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/session-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div class="meta">
<span class="time">
{{#if this.session.startsAt}}
{{moment-format this.session.startsAt 'D MMM, YYYY h:mm A'}}
{{general-date this.session.startsAt '' 'D MMM, YYYY h:mm A'}}
{{else}}
{{t 'Session Not Yet Scheduled'}}
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
</span>
{{else if this.record}}
<span>
{{moment-format this.record (if this.props.options.dateFormat this.props.options.dateFormat "D MMM, YYYY h:mm A")}}
{{general-date this.record '' (if this.props.options.dateFormat this.props.options.dateFormat "D MMM, YYYY h:mm A")}}
</span>
{{/if}}
4 changes: 2 additions & 2 deletions app/templates/components/ui-table/cell/cell-validity.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<span>
{{moment-format this.record 'D MMM, YYYY h:mm A'}}
{{general-date this.record '' 'D MMM, YYYY h:mm A'}}
<br>To<br>
{{moment-format this.extraRecords.validTill 'D MMM, YYYY h:mm A'}}
{{general-date this.extraRecords.validTill '' 'D MMM, YYYY h:mm A'}}
</span>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if (eq @record.status 'completed')}}
{{moment-format @record.completedAt "D MMM, YYYY h:mm A"}}
{{general-date @record.completedAt '' "D MMM, YYYY h:mm A"}}
{{else}}
{{moment-format @record.createdAt "D MMM, YYYY h:mm A"}}
{{general-date @record.createdAt '' "D MMM, YYYY h:mm A"}}
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</span>
{{/if}}
{{#if (eq this.record.status 'completed')}}
{{moment-format this.record.completedAt 'D MMM, YYYY h:mm A'}}
{{general-date this.record.completedAt '' 'D MMM, YYYY h:mm A'}}
{{moment-from-now this.record.completedAt}}
{{else}}
{{moment-format this.record.createdAt 'D MMM, YYYY h:mm A'}}
{{general-date this.record.createdAt '' 'D MMM, YYYY h:mm A'}}
{{moment-from-now this.record.createdAt}}
{{/if}}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span>
{{moment-format this.record 'D MMM, YYYY h:mm A'}}
{{general-date this.record '' 'D MMM, YYYY h:mm A'}}
</span>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{#if this.record}}
<div>
{{moment-format this.record 'MMMM DD, YYYY - hh:mm A'}}
{{general-date this.record '' 'D MMM, YYYY h:mm A'}}
</div>
{{else}}
<div>
{{moment-format this.extraRecords.createdAt 'MMMM DD, YYYY - hh:mm A'}}
{{general-date this.extraRecords.createdAt '' 'D MMM, YYYY h:mm A'}}
</div>
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
{{/if}}
<span class="muted text">
{{#if this.extraRecords.completedAt}}
{{moment-format this.extraRecords.completedAt 'D MMM, YYYY h:mm A'}} {{moment-from-now this.extraRecords.completedAt}}
{{general-date this.extraRecords.completedAt '' 'D MMM, YYYY h:mm A'}} {{moment-from-now this.extraRecords.completedAt}}
{{else}}
{{moment-format this.extraRecords.createdAt 'D MMM, YYYY h:mm A'}} {{moment-from-now this.extraRecords.createdAt}}
{{general-date this.extraRecords.createdAt '' 'D MMM, YYYY h:mm A'}} {{moment-from-now this.extraRecords.createdAt}}
{{/if}}
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/explore.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
{{/if}}
{{#if this.filters.start_date}}
<div class="ui mini label">
{{moment-format this.filters.start_date 'D MMM, YYYY'}}
{{general-date this.filters.start_date '' 'D MMM, YYYY'}}
<a href="#" role="button" {{action 'clearFilter' 'start_date'}}><i class="icon close"></i></a>
</div>
{{/if}}
{{#if this.filters.end_date}}
<div class="ui mini label">
{{moment-format this.filters.end_date 'D MMM, YYYY'}}
{{general-date this.filters.end_date '' 'D MMM, YYYY'}}
<a href="#" role="button" {{action 'clearFilter' 'end_date'}}><i class="icon close"></i></a>
</div>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion app/templates/orders/expired.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="row">
<div class="column">
<div class="ui small gray-text">
{{header-date this.model.event.startsAt}} - {{header-date this.model.event.endsAt}}
{{general-date this.model.event.startsAt}} - {{general-date this.model.event.endsAt}}
<br>
{{this.model.event.locationName}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/orders/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="row">
<div class="column">
<div class="ui small gray-text">
{{header-date this.model.order.event.startsAt}} - {{header-date this.model.order.event.endsAt}}
{{general-date this.model.order.event.startsAt}} - {{general-date this.model.order.event.endsAt}}
<br>
{{this.model.order.event.locationName}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/orders/pending.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="row">
<div class="column">
<div class="ui small gray-text">
{{header-date this.model.order.event.startsAt}} - {{header-date this.model.order.event.endsAt}}
{{general-date this.model.order.event.startsAt}} - {{general-date this.model.order.event.endsAt}}
<br>
{{this.model.order.event.locationName}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/orders/view.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="row print">
<div class="column">
<div class="ui small gray-text">
{{header-date this.model.order.event.startsAt}} - {{header-date this.model.order.event.endsAt}}
{{general-date this.model.order.event.startsAt}} - {{general-date this.model.order.event.endsAt}}
<br>
{{this.model.order.event.locationName}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/public/sessions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="d-flex wrap">
<LinkTo @route="public.sessions" @models={{array this.model.event.id}} @query={{hash date=null}} class="ui button mb-2">{{t 'All'}}</LinkTo>
{{#each this.allDates as |date|}}
<LinkTo @route="public.sessions" @models={{array this.model.event.id}} @query={{hash date=(moment-format date "YYYY-MM-DD")}} class="ui button mb-2">{{moment-format date 'D MMM, YYYY'}}</LinkTo>
<LinkTo @route="public.sessions" @models={{array this.model.event.id}} @query={{hash date=(moment-format date "YYYY-MM-DD")}} class="ui button mb-2">{{general-date date '' 'D MMM, YYYY'}}</LinkTo>
{{/each}}

<Widgets::TimeZonePicker
Expand Down
16 changes: 0 additions & 16 deletions tests/integration/helpers/header-date-test.js

This file was deleted.