From 94c3462515949c2016ee60c2e95317c6e6c15c22 Mon Sep 17 00:00:00 2001 From: billybonks Date: Sun, 25 Sep 2016 12:42:47 +0800 Subject: [PATCH] translate dob-days.js --- app/locales/en/translations.js | 10 ++++++++++ app/mixins/dob-days.js | 22 ++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index 6ef6cd960f..ff9e5bf985 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -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', diff --git a/app/mixins/dob-days.js b/app/mixins/dob-days.js index 0a91c65c28..14c5876488 100644 --- a/app/mixins/dob-days.js +++ b/app/mixins/dob-days.js @@ -44,27 +44,33 @@ export default Ember.Mixin.create({ } var formatString = ''; + options = { + years: years, + days: days, + months: months + } + 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;