From 90624b70903429c11002e44802a90786fb99d47d Mon Sep 17 00:00:00 2001 From: Isaac Ezer Date: Thu, 1 Dec 2016 13:02:43 -0500 Subject: [PATCH] allow runtime override of Ember.I18n Do not destructure before exporting. Fixes using `ember-i18n`. Otherwise the workaround [described here](https://github.com/DockYard/ember-validations/issues/366#issuecomment-169869004) using `ember-i18n` does not work. When running multiple tests, ember-validations will use a destroyed version of `i18n` from the 1st test run. --- addon/messages.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addon/messages.js b/addon/messages.js index d954934e..836ce4fd 100644 --- a/addon/messages.js +++ b/addon/messages.js @@ -1,11 +1,11 @@ import Ember from 'ember'; -const { I18n } = Ember; - export default { render(attribute, context) { - if (I18n) { - return I18n.t(`errors.${attribute}`, context); + // ember-i18n users may override this at runtime. + // jscs:disable disallowDirectPropertyAccess + if (Ember.I18n) { + return Ember.I18n.t(`errors.${attribute}`, context); } else { let regex = new RegExp('{{(.*?)}}'); let attributeName = '';