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

Macro inspired by ember-i18n #42

Closed
karellm opened this issue Mar 13, 2017 · 1 comment
Closed

Macro inspired by ember-i18n #42

karellm opened this issue Mar 13, 2017 · 1 comment
Milestone

Comments

@karellm
Copy link
Contributor

karellm commented Mar 13, 2017

I think the macro idea from ember-i18n is really neat: https://github.com/jamesarosen/ember-i18n/wiki/Doc:-Translating-Text#translation-computed-property-macro

It would be nice to have that here too. For now I ported the code to my project but if it is something you want maybe I can work on a PR.

@heathharrelson
Copy link
Member

heathharrelson commented Apr 6, 2017

Sorry for the slow response. I wasn't aware of this macro in ember-i18n, and I like the idea a lot. However, I'm not crazy about the syntax used in ember-i18n, because it doesn't match most computed property macros. Using the example from the documentation above, I would prefer something that looked like this:

import { translationMacro as t } from "ember-i18next";

export default Ember.Component.extend({
  // A simple translation.
  title: t('user.edit.title'),

  followersCount: 1,
  count: Ember.computed.alias('followersCount'),

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

The main difference being that the arguments to the macro are dependent property names rather than an options hash.

I'd be happy to accept a PR that matches the example above. No worries if you don't currently have the time; I can quickly implement it myself before the next release.

@heathharrelson heathharrelson added this to the 2.0 milestone Apr 6, 2017
@heathharrelson heathharrelson modified the milestones: 2.0, 2.1 Mar 1, 2018
@karellm karellm mentioned this issue Mar 15, 2018
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants