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

Commit

Permalink
translate dob-days.js
Browse files Browse the repository at this point in the history
  • Loading branch information
billybonks committed Sep 25, 2016
1 parent 623307d commit 1408763
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
10 changes: 10 additions & 0 deletions app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ export default {
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',
inventory: 'Inventory',
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

0 comments on commit 1408763

Please sign in to comment.