I'm using the bower version of l20n to localize an ember-cli app.
I'm localizing the app using the following flow:
I've created an initializer which creates an l20n context object based off of the user's language setting.
Using an ember helper, I pass each word from the DOM onto the l20n context object to be translated.
In handlebars template :
{{l20n-helper 'stringVariable'}}
In ember helper:
export function translate(word){
return Ember.l20n.getSync(word);
}
export default Ember.Handlebars.makeBoundHelper(translate);
This works, but I've just tagged a global variable onto Ember in order to make the l20n context accessible to the helper. I know that is not best practice. I'm trying to figure out how to create an ES6 module that will serve only to store the l20n context object. That way, inside my ember helper, I could just do:
import l20n from "/????"
and prevent the l20n object from bogging down the rest of the app.
Thanks in advance for any help!!!
Update:
One solution is to use application.register, like so:
application.register('l20n:main', ctx, {instantiate: false});
BUT, then my problem would be accessing the container from my helper. This:
var l20n = this.container.lookup('l20n:main');
won't work because container is not available to helpers!