jamesarosen / ember-i18n

Other
764 stars 184 forks source link

Setting I18N_COMPILE_WITHOUT_HANDLEBARS environment variable before including i18n causes build headaches #134

Closed blimmer closed 10 years ago

blimmer commented 10 years ago

It's awesome that we have a new handlebars-less compiler to use with i18n. However, it was harder than I would have hoped to set the appropriate environment variable to enable it.

According to the README:

Set Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS = true; before including ember-i18n to 
use the new translation compiler that does not depend on the full Handlebars.

That's a bit of a pain because I use Bower to include ember and ember i18n in a vendor.js file (produced by brunch). Therefore, I had to create a single line fine to include before ember i18n that sets this environment variable and include it in an ordering directive.

It would be great if I could set this before calling my App.create, like other Ember.FEATURES. At the very least, it would be awesome if the message in the console (Ember.I18n will no longer include Handlebars compilation by default in the future; instead, it will supply its own default compiler. Set Ember.ENV.I18N_COMPILE_WITHOUT_HANDLEBARS to true to opt-in now.) didn't appear in production.

jamesarosen commented 10 years ago

The standard practice for Ember.ENV flags looks something like

<script>
ENV = {
  I18N_COMPILE_WITHOUT_HANDLEBARS: true,
  SOME_OTHER_FLAG: 'debug'
};
</script>
<script src="/js/vendor.js"></script>
<script src="/js/application.js"></script>

Can you not seed window.ENV before including vendor.js for some reason?

blimmer commented 10 years ago

Excellent, sorry this must have been my misunderstanding.

EDIT: As a follow up, I guess I was confused on how to set Ember.ENV values in general. I didn't realize you could set them on window. I thought that I would need to have included Ember, then this env variable, then i18n which would have been a pain.