Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any tips on how I can use this in an ember-cli project? #5

Open
simonexmachina opened this issue Nov 5, 2014 · 1 comment
Open

Comments

@simonexmachina
Copy link

Happy to help out, just want to know how I should approach it.

@jenseng
Copy link
Collaborator

jenseng commented Nov 5, 2014

@aexmachina we're still sorting out some of the details, and some of it might end up in a new project that uses i18nliner-handlebars as its foundation (maybe i18nliner-ember?). In the meantime it should be possible to make it work with a little bit of duct tape...

  1. You'll need to hook into ember-cli's handlebars compilation so that i18nliner's pre-processor can do its thing. I haven't dug into it too much to know where, but the gist of it is you need to give EmberHandlebars a pre-processed AST rather than the source string, e.g.

    // somewhere inside ember-cli / ember-template-compiler ... assuming we have a `source` var 
    var Handlebars = require('handlebars');
    var ast = Handlebars.parse(source);
    var PreProcessor = require('i18nliner-handlebars/dist/lib/pre_processor')['default'];
    PreProcessor.process(ast);
    var result = EmberHandlebars.precompile(ast).toString();
    // do whatever you usually do with result
  2. You'll need some runtime scripts:

    1. i18n.js
    2. i18nliner's i18n.js extensions
    3. i18nliner handlebars helpers for ember ... see here for something that ought to work.

So yeah, it takes a little bit to wire everything up, but it's not too terrible. I'm using i18nliner in three different ember apps atm, but none of them uses ember-cli (one broccoli, one grunt, and one franken-guard). We'll definitely be improving this in the near term, so watch this space. I'll post some updates and close this ticket once the plan solidifies a bit more.

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

No branches or pull requests

2 participants