Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Access translations from inside hbs helpers #279

Closed
unHuesio opened this issue Jul 20, 2015 · 5 comments
Closed

Access translations from inside hbs helpers #279

unHuesio opened this issue Jul 20, 2015 · 5 comments

Comments

@unHuesio
Copy link

how do you access a translation from inside a helper?

export function groupLink(params/*, hash*/) {
        url = "somethingfromparams";
    return new Ember.Handlebars.SafeString('<a href="'+url+'">'+t("translatedText")+'</a>');
}
@jamesarosen
Copy link
Owner

You'll need to use the new "stateful helper" form to get access to the service:i18n in a helper. See emberjs/rfcs#53.

@unHuesio
Copy link
Author

awesome, thanks!

@galfert
Copy link

galfert commented Aug 6, 2015

The "stateful helper" are only available in Ember 1.13. How do I access the t helper in a helper in Ember 1.12?

@jamesarosen
Copy link
Owner

If Ember-I18n sees that you're on 1.12, it uses the private Stream API instead of a stayed up helper. You don't need to do anything different.

@jamesarosen
Copy link
Owner

Sorry, I misunderstood your most recent question.

I don't think there's a good way to do this in 1.12. Sorry.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants