How to use the ember-intl/-private/empty-object 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 / ember-intl / addon / macros / t.js View on Github external
export default function createTranslatedComputedProperty(translationKey, options) {
  const hash = options || new EmptyObject();
  const [dynamicValues, staticValues] = partitionDynamicValuesAndStaticValues(hash);
  const dependentKeys = Object.values(dynamicValues);

  return intl(...dependentKeys, (intl, propertyKey, ctx) =>
    intl.t(translationKey, assign({}, staticValues, mapPropertiesByHash(ctx, dynamicValues)))
  );
}
github ember-intl / ember-intl / addon / macros / t.js View on Github external
function mapPropertiesByHash(object, hash) {
  const result = new EmptyObject();

  Object.keys(hash).forEach(key => {
    result[key] = get(object, hash[key]);
  });

  return result;
}
github ember-intl / ember-intl / addon / macros / t.js View on Github external
function partitionDynamicValuesAndStaticValues(options) {
  const dynamicValues = new EmptyObject();
  const staticValues = new EmptyObject();

  Object.keys(options).forEach(key => {
    const value = options[key];
    if (value instanceof Raw) {
      staticValues[key] = value.valueOf();
    } else {
      dynamicValues[key] = value;
    }
  });

  return [dynamicValues, staticValues];
}
github ember-intl / ember-intl / addon / macros / t.js View on Github external
function partitionDynamicValuesAndStaticValues(options) {
  const dynamicValues = new EmptyObject();
  const staticValues = new EmptyObject();

  Object.keys(options).forEach(key => {
    const value = options[key];
    if (value instanceof Raw) {
      staticValues[key] = value.valueOf();
    } else {
      dynamicValues[key] = value;
    }
  });

  return [dynamicValues, staticValues];
}