messageformat / Jed

Gettext Style i18n for Modern JavaScript Apps
http://messageformat.github.io/Jed
MIT License
873 stars 68 forks source link

Bind methods #49

Open tarikjn opened 8 years ago

tarikjn commented 8 years ago

Currently one cannot do:

const {gettext} = i18n
gettext('Hello, World.')

As this would return:

TypeError: Cannot read property 'call' of undefined

However it seem fairly important to be able to shorten notations for views/renders with a lot of strings and for clarity of context.

Would it make sense to add a property accessor that would return an object listing those method as bound vs. call? This would also allow destructuring to get the needed methods.

SlexAxton commented 8 years ago

Seems reasonable. Would you be into PRing a solution to this with a test?

Thanks!

Suhoy95 commented 7 years ago

In my project i try do the similar thing. I create Jed object in intermediate module and export function are tied to the object.

This functions in library may be ok with simple project, but i think that bindings will be made in user's code to control state of Jed object explicitly.