Created
February 18, 2015 00:17
-
-
Save wagenet/d11775dcc11bf09d410c 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
import Stream from 'ember-cli-i18n/utils/stream'; | |
import t from 'ember-cli-i18n/utils/t'; | |
import Ember from 'ember'; | |
// tHelper without the container and application dependencies, sigh... | |
function tHelper(params /*, hash, options, env */) { | |
var path = params.shift(); | |
var stream = new Stream(function() { | |
return t(path, params); | |
}); | |
// bind any arguments that are Streams | |
for (var i = 0, l = params.length; i < l; i++) { | |
var param = params[i]; | |
if(param && param.isStream){ | |
param.subscribe(stream.notify, stream); | |
} | |
} | |
if (path.isStream) { | |
path.subscribe(stream.notify, stream); | |
} | |
return stream; | |
} | |
export function registerI18N() { | |
// Yay, private APIs! | |
Ember.HTMLBars._registerHelper('t', tHelper); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, I am wondering the same!