How to use ember-intl - 10 common examples

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 hummingbird-me / hummingbird-client / app / components / modals / media-review.js View on Github external
import Component from 'ember-component';
import get from 'ember-metal/get';
import set from 'ember-metal/set';
import service from 'ember-service/inject';
import computed, { alias } from 'ember-computed';
import { isPresent } from 'ember-utils';
import { task } from 'ember-concurrency';
import { translationMacro as t } from 'ember-intl';

export default Component.extend({
  classNames: ['review-modal'],
  intl: service(),
  metrics: service(),
  store: service(),
  rating: alias('review.libraryEntry.rating'),
  errorMessage: t('errors.request'),

  isValid: computed('rating', 'review.content', function() {
    return (get(this, 'rating') > 0) && isPresent(get(this, 'review.content'));
  }).readOnly(),

  init() {
    this._super(...arguments);
    // make sure the required data is loaded into the mode
    get(this, 'loadReview').perform().then(() => {
      get(this, 'loadRelationships').perform();
    }).catch(() => {});
  },

  willDestroyElement() {
    this._super(...arguments);
    get(this, 'review').rollbackAttributes();
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
}
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
}
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
}
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
}
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
}
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
}
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
github ember-intl / ember-intl / app / initializers / ember-intl-legacy.js View on Github external
export function initialize(registry, app = {}) {
  registerHelper('format-date', FormatDate, registry);
  registerHelper('format-time', FormatTime, registry);
  registerHelper('format-relative', FormatRelative, registry);
  registerHelper('format-number', FormatNumber, registry);
  registerHelper('format-html-message', FormatHtmlMessage, registry);
  registerHelper('format-message', FormatMessage, registry);
  registerHelper('t', FormatMessage, registry);
  registerHelper('l', LiteralHelper, registry);

  if (app.instanceInitializer) {
    return;
  }

  // for backwards compatability < 1.12
  instanceInitializer({
    container: registry
  });
}
github ember-intl / decorators / addon / intl.ts View on Github external
export default (decoratorWithParams(function intl(
  target: Target,
  key: keyof Target,
  desc: PropertyDescriptor & { initializer: () => GetterFn },
  dependentKeys: string[] = []
) {
  const value: GetterFn = desc.value;
  const initializer: () => GetterFn = desc.initializer;
  delete desc.value;
  delete desc.initializer;

  const cp = intlMacro(...dependentKeys, function(
    intl: IntlService, // eslint-disable-line no-shadow
    propertyKey: string
  ) {
    const fn: GetterFn = value || initializer.call(this);
    assert(
      `@intl: You need to decorate a function, but you decorated '${fn}'.`,
      typeof fn === 'function'
    );

    return fn.call(this, intl, propertyKey);
  });

  // @ts-ignore
  return cp(target, key, desc);
}) as unknown) as ((
  ...args: Parameters