How to use the ember-intl/utils/locale function in ember-intl

To help you get started, we’ve selected a few ember-intl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HospitalRun / hospitalrun-frontend / app / utils / i18n / missing-message.js View on Github external
let missingMessage = function(locale, key, data) {
  if (locale === DEFAULT_LOCALE || window.env === 'development') {
    return `Missing translation: ${key}`;
  } else {

    Ember.Logger.warn(`Missing translation: ${key}`);

    // NOTE This relies on internal APIs and is brittle.
    // Emulating the internals of ember-intl's translate method
    let intl = this;
    let count = Ember.get(data, 'count');
    let defaults = Ember.makeArray(Ember.get(data, 'default'));
    defaults.unshift(key);
    let localeObj = new Locale(DEFAULT_LOCALE, Ember.getOwner(intl));
    let template = localeObj.getCompiledTemplate(defaults, count);
    return template(data);
  }
};