Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Translate/mixins #671

Merged
merged 2 commits into from
Sep 27, 2016
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
13 changes: 12 additions & 1 deletion app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ export default {
otherThan: 'must be other than {{count}}',
odd: 'must be odd',
even: 'must be even',
invalidNumber: 'not a valid number'
invalidNumber: 'not a valid number',
result: 'Please enter a result before completing'
},
dates: {
long: '{{years}} year {{months}} months {{days}} days',
longPlural: '{{years}} years {{months}} months {{days}} days',
longOmitYears: '{{months}} months {{days}} days',
longOmitDays: '{{years}} year {{months}} months',
longOmitDaysPlural: '{{years}} years {{months}} months',
longOmitDaysYears: '{{months}} months',
shortOmitYears: '{{months}}m {{days}}d',
short: '{{years}}y {{months}}m {{days}}d'
},
navigation: {
imaging: 'Imaging',
Expand Down
22 changes: 14 additions & 8 deletions app/mixins/dob-days.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,33 @@ export default Ember.Mixin.create({
}

var formatString = '';
let options = {
years: years,
days: days,
months: months
};
let t = this.get('i18n').t;
if (shortFormat) {
if (years > 0) {
formatString = `${years}y ${months}m ${days}d`;
formatString = t('dates.short', options);
} else {
formatString = `${months}m ${days}d`;
formatString = t('dates.shortOmitYears', options);
}
} else if (omitDays) {
if (years > 1) {
formatString = `${years} years ${months} months`;
formatString = t('dates.longOmitDaysPlural', options);
} else if (years === 1) {
formatString = `${years} year ${months} months`;
formatString = t('dates.longOmitDays', options);
} else {
formatString = `${months} months`;
formatString = t('dates.longOmitDaysYears', options);
}
} else {
if (years > 1) {
formatString = `${years} years ${months} months ${days} days`;
formatString = t('dates.longPlural', options);
} else if (years === 1) {
formatString = `${years} year ${months} months ${days} days`;
formatString = t('dates.long', options);
} else {
formatString = `${months} months ${days} days`;
formatString = t('dates.longOmitYears', options);
}
}
return formatString;
Expand Down
4 changes: 3 additions & 1 deletion app/mixins/result-validation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Ember from 'ember';
import { translationMacro as t } from 'ember-i18n';

export default Ember.Mixin.create({
validations: {
result: {
Expand All @@ -16,7 +18,7 @@ export default Ember.Mixin.create({
}
return false;
},
message: 'Please enter a result before completing'
message: t('errors.result')
}
}
}
Expand Down