Skip to content

Instantly share code, notes, and snippets.

@tim-evans
Last active December 19, 2015 18:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-evans/6002558 to your computer and use it in GitHub Desktop.
Save tim-evans/6002558 to your computer and use it in GitHub Desktop.
/**
The `{{t}}` helper renders a localized string using `I18n.t`.
```handlebars
{{t "app.hello_world"}}
```
```html
Hello, World!
```
To pass parameters to the localization function, simply
specify them as parameters to the localization helper
like you would to a `{{view}}` helper.
```handlebars
{{t "app.ordinals" count=2}}
```
```html
2nd
```
If the localization string is generated via a bound value,
you may generate your string by specifying the bound values
using quasi-literal syntax:
```handlebars
{{t "app.status.`currentStatus`"}}
```
```html
Available
```
@method t
@for Em.Handlebars.helpers
@param string {String} The string to localize
@param formats {Object} An object to format the string with.
@return {String} HTML string
*/
Ember.Handlebars.registerTextHelper('t', function (text, context) {
return I18n.t(text, context);
}, /`(.*?)`/g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment