martinandert / counterpart

A translation and localization library for Node.js and the browser.
MIT License
242 stars 25 forks source link

Added onTranslate hook to the translate function #27

Closed rvdkooy closed 9 years ago

rvdkooy commented 9 years ago

This pull request will make it possible to interact with the parameters of the translate function on a global level. I am experiencing an issue with counterpart where it is not possible to lowercase my keys when translating.

My original translations are not consistent (pascalcase, camelcase, etc), so the only thing that I can do with them to make them consistent is to lowercase the keys, but therefore counterpart also needs to lowercase them. By adding this hook I can do:

counterpart.registerOnTranslate(function(args) {
    args.key.toLowerCase();
); 

please let me know if you think this feature is worth adding to counterpart

Thanks a lot!

Ronald

martinandert commented 9 years ago

Thanks for your pull request, Ronald! Based on your idea, I've added something similar to v0.17 (see commit https://github.com/martinandert/counterpart/commit/e7e87a3fda344a38dfa32bd5a7c647b8780261e3). I hope this is going to work for you. If not, please let me know.

rvdkooy commented 9 years ago

Great, That will definitely work

thanks a lot!

rvdkooy commented 9 years ago

Oh by the way: we are using your react-translate-component, when do you think you can update this with version 0.17 of counterpart?

martinandert commented 9 years ago

Oh by the way: we are using your react-translate-component, when do you think you can update this with version 0.17 of counterpart?

Updating it as we speak.