-
-
Save tim-evans/6002558 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
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