Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow literal / raw values in translation macro / decorator #625

Closed
buschtoens opened this issue Oct 17, 2018 · 0 comments
Closed

Allow literal / raw values in translation macro / decorator #625

buschtoens opened this issue Oct 17, 2018 · 0 comments

Comments

@buschtoens
Copy link
Member

As suggested in #624 (comment).

The translation macro (and soon decorator #623) currently only allow the user to pass keys that will then be used to retrieve the values to be used for interpolating the translation strings: Docs

import Component from '@ember/component':
import { translationMacro as t } from 'ember-intl';

export default Component.extend({
  followersCount: 1,

  // A translation with interpolations. This computed property
  // depends on `count` and will send `{ count: this.followersCount }`
  // in to the translation.
  followersTitle: t('user.followers.title', { count: 'followersCount' })
});

Assume the count variable is static. We can't pass { count: 1 }, instead we need to go through one unnecessary step of redirection by setting followersCount: 1 and then passing { count: 'followersCount' }.

We propose adding a raw function like in ember-awesome-macros / ember-macro-helpers:

import Component from '@ember/component':
import { translationMacro as t, raw } from 'ember-intl';

export default Component.extend({
  // A translation with static interpolations. This computed property
  // has no dependencies (other than the implicit `intl.locale`)
  // and will send `{ count: 1 }`
  followersTitle: t('user.followers.title', { count: raw(1) })
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant