How to use the ember-intl.intl 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 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