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

Commit

Permalink
Merge pull request #671 from billybonks/translate/mixins
Browse files Browse the repository at this point in the history
Translate/mixins
  • Loading branch information
jkleinsc authored Sep 27, 2016
2 parents d243f1a + 1408763 commit 6c2a37c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
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

0 comments on commit 6c2a37c

Please sign in to comment.