From 140876315abe364f89c3e648470482edea47bcfa 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..c30f9a5674 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..3b4d5767f3 100644 --- a/app/mixins/dob-days.js +++ b/app/mixins/dob-days.js @@ -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;