formatjs / handlebars-intl

Handlebars helpers for internationalization.
http://formatjs.io/handlebars/
Other
265 stars 28 forks source link

Programmatic Access #54

Closed justinmc closed 9 years ago

justinmc commented 9 years ago

I'm using this for internationalizing my handlebars templates and it works great, but I also have a few strings in javascript that I can't move into a template. I'd like to be able to internationalize these with a programmatic interface. It seems I have to include intl-messageformat by itself in order to do this, even though handlebars-intl includes it already. It seems wasteful to include it twice, why can't I reference intl-messageformat through handlebars-intl?

caridy commented 9 years ago

yeah, we discussed this use case in depth, and we came to the conclusion that you can create your own distro of handlebars-intl that can expose multiple things into the global namespace if needed. we strongly believe that translations should not be part of the code, but keys can, in which case, you can stiff just pass the keys around, and use the keys in the template as {{formatMessage valueWithMyKey}} and it will work just find.

If this does not suit you well, for whatever reason, let us know and we will revisit the issue. We do have a better infrastructure today, which will allow us to expose those internals form the bundle, but we really really believe this is not needed.

justinmc commented 9 years ago

That makes sense and I understand why you guys went this way. I'm going to go with your approach and see how it works out. If I run into any problems or have any suggestions for doing this, I'll post back here. Thanks.

caridy commented 9 years ago

@justinmc awesome, we did discuss this request yesterday, and @ericf has some other ideas that might workout well and will solve this particular use case in a very organic way, but it will take time (not a priority at this point).