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

chore: Correct l10n service usage #5354

Merged
merged 3 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all 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/components/account/application-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class ApplicationSection extends Component {
});
}
} catch (error) {
this.notify.error(this.l10n.t(error.message), {
this.notify.error(error.message, {
id: 'error_message'
});
this.set('isLoading', false);
Expand Down
2 changes: 1 addition & 1 deletion app/components/events/view/export/download-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class DownloadZip extends Component {
});
} catch (e) {
console.error('Error while downloading event zip', e);
this.notify.error(this.l10n.t(e), {
this.notify.error(e, {
id: 'err_down'
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/forms/admin/settings/system-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default Component.extend(FormMixin, {
},
{
type : 'email',
prompt : this.l10n.t('Please enter a valid email address')
prompt : this.l10n.t('Please enter a valid email address')
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions app/components/forms/orders/order-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export default Component.extend(FormMixin, {
rules : [
{
type : 'empty',
prompt : this.l10n.t('Please enter your city ')
prompt : this.l10n.t('Please enter your city')
}
]
},
Expand Down Expand Up @@ -476,7 +476,7 @@ export default Component.extend(FormMixin, {
rules: [
{
type : 'empty',
prompt : this.l10n.t('Please enter ' + field.name)
prompt : 'Please enter ' + field.name
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion app/components/forms/session-speaker-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export default Component.extend(FormMixin, {
rules: [
{
type : 'empty',
prompt : this.l10n.t('Please enter ' + field.name)
prompt : 'Please enter ' + field.name
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion app/components/forms/wizard/basic-details-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export default Component.extend(FormMixin, EventWizardMixin, {
})
.catch(error => {
console.error('Error while setting stripe authorization in event', error);
this.notify.error(this.l10n.t(`${error.message}. Please try again`), {
this.notify.error(error.message + '. ' + this.l10n.t('Please try again'), {
id: 'basic_detail_err'
});
});
Expand Down
2 changes: 1 addition & 1 deletion app/components/forms/wizard/custom-form-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
<div class="item" data-value="number">Number</div>
</div>
</UiDropdown>
<button class="ui button" {{action 'addFormField'}} disabled={{not this.validIdentifier}}>{{t (if @field 'Save' 'Add')}}</button>
<button class="ui button" {{action 'addFormField'}} disabled={{not this.validIdentifier}}>{{if @field (t 'Save') (t 'Add')}}</button>
</div>
2 changes: 1 addition & 1 deletion app/components/forms/wizard/custom-forms/table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{#if @headerText}}
<tr>
<th colspan="{{if this.editColumn '5' '4'}}" class="text center aligned">
{{t @headerText}}
{{@headerText}}
</th>
</tr>
{{/if}}
Expand Down
5 changes: 4 additions & 1 deletion app/components/public/ticket-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,10 @@ export default Component.extend(FormMixin, {
rules : [
{
type : `integer[${donationTicket.minPrice}..${donationTicket.maxPrice}]`,
prompt : this.l10n.t(`Please enter a donation amount between ${donationTicket.minPrice} and ${donationTicket.maxPrice}`)
prompt : this.l10n.t('Please enter a donation amount between {{minPrice}} and {{maxPrice}}', {
minPrice : donationTicket.minPrice,
maxPrice : donationTicket.maxPrice
})
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion app/components/unverified-user-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class UnverifiedUserMessage extends Component {
.catch(error => {
console.error('Error while sending verification email', error, error.error);
if (error.error) {
this.notify.error(this.l10n.t(error.error), {
this.notify.error(error.error, {
id: 'ver_mail_serv_error'
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/account/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class extends Controller {
.catch(error => {
console.error('Error while updating password', error);
if (error.errors) {
this.notify.error(this.l10n.t(`${error.errors[0].detail}`),
this.notify.error(error.errors[0].detail,
{
id: 'err_pass_ser'
});
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/account/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class extends Controller {
});
} catch (error) {
console.error('Error while updating contact info', error);
this.notify.error(this.l10n.t(error.message),
this.notify.error(error.message,
{
id: 'cont_upd_error'
});
Expand Down
20 changes: 12 additions & 8 deletions app/controllers/admin/content/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,21 @@ export default class extends Controller {
modelInstance.save()
.then(() => {
this.get(`model.${camelCasedValue}s`).addObject(modelInstance);
this.notify.success(this.l10n.t(`${startCase(camelCasedValue)} has been added successfully.`),
{
id: 'mode_add_succ'
});
this.notify.success(this.l10n.t('{{item}} has been added successfully.', {
item: startCase(camelCasedValue)
}),
{
id: 'mode_add_succ'
});
})
.catch(e => {
console.error('Error while adding ' + camelCasedValue, e);
this.notify.error(this.l10n.t(`An unexpected error has occurred. ${startCase(camelCasedValue)} not saved.`),
{
id: 'mode_err_succ'
});
this.notify.error(this.l10n.t('An unexpected error has occurred.') + this.l10n.t('{{item}} not saved.', {
item: startCase(camelCasedValue)
}),
{
id: 'mode_err_succ'
});
})
.finally(() => {
this.set('isLoading', false);
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/events/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
const event = this.store.peekRecord('event', event_id, { backgroundReload: false });
event.toggleProperty('isPromoted');
await event.save();
this.notify.success(this.l10n.t(`Event ${event.isPromoted ? 'Promoted' : 'unpromoted'} Successfully`),
this.notify.success(event.isPromoted ? this.l10n.t('Event promoted successfully') : this.l10n.t('Event unpromoted successfully'),
{
id: 'event_detail_changed'
});
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class extends Controller {
});
} catch (e) {
console.error('Error while saving system messages', e);
this.notify.error(this.l10n.t(e.errors[0].detail),
this.notify.error(e.errors[0].detail,
{
id: 'change_error_message'
});
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/permissions/event-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class extends Controller {
})
.catch(err => {
console.error('Error while saving admin event role permissions', err);
this.notify.error(this.l10n.t(err),
this.notify.error(err,
{
id: 'admin_event_error'
});
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/events/view/edit/attendee.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class AttendeeController extends Controller.extend(EventWizardMix
);
} catch (error) {
console.error('Error while updating attendee', error);
this.notify.error(this.l10n.t(error.message),
this.notify.error(error.message,
{
id: 'attendee_error_serv'
});
Expand All @@ -37,7 +37,7 @@ export default class AttendeeController extends Controller.extend(EventWizardMix
);
} catch (error) {
console.error('Error while moving attendee', error);
this.notify.error(this.l10n.t(error.message),
this.notify.error(error.message,
{
id: 'attendee_move_error'
});
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/events/view/edit/other-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class OtherDetailsController extends Controller.extend(EventWizar
);
} catch (error) {
console.error('Error while moving attendee', error);
this.notify.error(this.l10n.t(error.message),
this.notify.error(error.message,
{
id: 'attendee_move_error'
});
Expand Down
17 changes: 10 additions & 7 deletions app/controllers/events/view/sessions/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
const { isLocked } = session;
session.set('isLocked', lock);
this.set('isLoading', true);
const lockMessage = lock ? 'locked' : 'unlocked';
const lockMessage = lock ? this.l10n.t('locked') : this.l10n.t('unlocked');
try {
await session.save();
this.notify.success(this.l10n.t(`Session has been ${ lockMessage } successfully.`),
{
id: 'session_lock'
});
this.notify.success(this.l10n.t('Session has been {{action}} successfully.', {
action: lockMessage
}),
{
id: 'session_lock'
});
this.refreshModel.bind(this)();
} catch (e) {
session.set('isLocked', isLocked);
Expand All @@ -173,8 +175,9 @@ export default class extends Controller.extend(EmberTableControllerMixin) {

try {
await session.save();
const message = `Session has been ${state}`;
this.notify.success(this.l10n.t(message), {
this.notify.success(this.l10n.t('Session has been {{action}} successfully.', {
action: state
}), {
id: 'session_state'
});
this.refreshModel.bind(this)();
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/events/view/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class extends Controller {
});
this.notify.success(this.l10n.t('Owner Role Invite sent successfully.'));
} catch (error) {
this.notify.error(this.l10n.t(error.message));
this.notify.error(error.message);
}

this.set('isLoading', false);
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/events/view/tickets/attendees.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export default class AttendeesController extends Controller {
this.requestLoop(exportJobInfo);
this.notify.alert(this.l10n.t('Task is going on.'));
} else {
this.notify.error(this.l10n.t(`${mode.toUpperCase()} Export has failed.`));
this.notify.error(mode.toUpperCase() + ' ' + this.l10n.t('Export has failed.'));
}
})
.catch(() => {
this.notify.error(this.l10n.t(`${mode.toUpperCase()} Export has failed.`));
this.notify.error(mode.toUpperCase() + ' ' + this.l10n.t('Export has failed.'));
})
.finally(() => {
this.set('isLoading', false);
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/events/view/tickets/attendees/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
}
attendee.save()
.then(savedAttendee => {
this.notify.success(this.l10n.t(`Attendee ${savedAttendee.isCheckedIn ? 'Checked-In' : 'Checked-Out'} Successfully`));
const message = savedAttendee.isCheckedIn ? this.l10n.t('Attendee Checked-In Successfully') : this.l10n.t('Attendee Checked-Out Successfully');
this.notify.success(message);
this.refreshModel.bind(this)();
})
.catch(() => {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/events/view/tickets/order-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class OrderFormController extends Controller {
})
.catch(e => {
console.error(e);
this.notify.error(this.l10n.t(e.errors[0].detail));
this.notify.error(e.errors[0].detail);
})
.finally(() => {
this.set('isLoading', false);
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/events/view/tickets/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export default class OrdersController extends Controller {
this.requestLoop(exportJobInfo);
this.notify.alert(this.l10n.t('Task is going on.'));
} else {
this.notify.error(this.l10n.t(`${mode.toUpperCase()} Export has failed.`));
this.notify.error(mode.toUpperCase() + ' ' + this.l10n.t('Export has failed.'));
}
})
.catch(() => {
this.notify.error(this.l10n.t(`${mode.toUpperCase()} Export has failed.`));
this.notify.error(mode.toUpperCase() + ' ' + this.l10n.t('Export has failed.'));
})
.finally(() => {
this.set('isLoading', false);
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/orders/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class NewController extends Controller {
.catch(e => {
console.error('Error while saving new order', e);
order.set('status', 'initializing');
this.notify.error(this.l10n.t(` ${e} Oops something went wrong. Please try again`),
this.notify.error(e + ': ' + this.l10n.t('Oops something went wrong. Please try again'),
{
id: 'order_stat_error'
});
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/orders/pending.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class PendingController extends Controller {
});
window.location.replace(res.link);
} catch (error) {
this.notify.error(this.l10n.t(error.error));
this.notify.error(error.error);
}
}

Expand All @@ -73,7 +73,7 @@ export default class PendingController extends Controller {
'txnToken' : res.body.txnToken
});
} catch (error) {
this.notify.error(this.l10n.t(error.error));
this.notify.error(error.error);
}
}

Expand All @@ -92,7 +92,7 @@ export default class PendingController extends Controller {
'isOTPModalOpen' : true
});
} catch (error) {
this.notify.error(this.l10n.t(error.error));
this.notify.error(error.error);
}
}

Expand All @@ -109,7 +109,7 @@ export default class PendingController extends Controller {
'isOTPModalOpen': false
});
} catch (error) {
this.notify.error(this.l10n.t(error.error));
this.notify.error(error.error);
}
}

Expand Down
10 changes: 6 additions & 4 deletions app/controllers/public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class IndexController extends Controller {
if (error.errors[0].status === 409) {
this.set('userExists', true);
} else {
this.notify.error(this.l10n.t(error.errors[0].detail));
this.notify.error(error.errors[0].detail);
}
}
})
Expand Down Expand Up @@ -118,21 +118,23 @@ export default class IndexController extends Controller {
const { orderInput } = this;
try {
const order = await this.loader.post('/orders/create-order', orderInput);
this.notify.success(this.l10n.t(`Order details saved. Please fill further details within ${this.settings.orderExpiryTime} minutes.`));
this.notify.success(this.l10n.t('Order details saved. Please fill further details within {{time}} minutes.', {
time: this.settings.orderExpiryTime
}));
this.transitionToRoute('orders.new', order.data.attributes.identifier);
} catch (e) {
if (e.response?.errors[0]?.source?.code === 'unverified-user') {
console.warn('Unverified user placing order', e.response);
} else {
console.error('Error while saving order', e);
}
this.notify.error(this.l10n.t(e.response.errors[0].detail));
this.notify.error(e.response.errors[0].detail);
} finally {
this.set('isLoading', false);
}
} catch (e) {
console.error('Error while creating order', e);
this.notify.error(this.l10n.t(e));
this.notify.error(e);
}
}
}
2 changes: 1 addition & 1 deletion app/routes/account/billing/invoices/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class extends Route.extend(EmberTableRouteMixin) {

titleToken() {
if (['paid', 'due', 'refunding', 'refunded'].includes(this.params.invoice_status)) {
return this.l10n.t(capitalize(this.params.invoice_status));
return capitalize(this.params.invoice_status);
} else {
return this.l10n.t('All');
}
Expand Down
2 changes: 1 addition & 1 deletion app/routes/admin/sessions/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SESSION_STATES } from 'open-event-frontend/utils/dictionary/sessions';
export default class extends Route.extend(EmberTableRouteMixin) {
titleToken() {
if ([...SESSION_STATES, 'deleted'].includes(this.params.sessions_state)) {
return this.l10n.t(capitalize(this.params.sessions_state));
return capitalize(this.params.sessions_state);
} else {
return this.l10n.t('Session');
}
Expand Down
2 changes: 1 addition & 1 deletion app/routes/events/view/sessions/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-rout
export default class EditRoute extends Route.extend(AuthenticatedRouteMixin) {
titleToken(model) {
const sessionTitle = model.session.title;
return this.l10n.t(sessionTitle.concat('-Edit'));
return sessionTitle.concat(' - Edit');
}

async model(params) {
Expand Down
Loading