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

Add translateFuncName option to Translate HOC #196

Merged
merged 2 commits into from
Aug 10, 2016

Conversation

rarguelloF
Copy link
Contributor

@rarguelloF rarguelloF commented Aug 10, 2016

Hello guys, I've already started using your lib and it's amazing, thanks!

I've found a little issue using while using it, so that's why I'm creating this PR.

In the project I'm currently working on, we are extracting the original chains from the source files using xgettext and looking for certain function names within the source files, so I found really useful to include an option to specify the name of the property the child components will use for accessing the translation function.

The usage would be the following:

export default translate(['namespace'], { wait: true, translateFuncName: 'gettext' })(TranslatedComponent);

Cheers and thanks in advance!

This is a non-mandatory option, with it's default value set to 't', same as before.
@jamuhl
Copy link
Member

jamuhl commented Aug 10, 2016

So basically you use t function from i18next but prefer to have it named xgettext? Or do you not use i18next but some other provider to set the i18n context?

@rarguelloF
Copy link
Contributor Author

rarguelloF commented Aug 10, 2016

Yes, I'm using i18next for translations.

I'm using xgettext for extracting the original chains from the source code, and as it's already configured, it's looking for a function named gettext. I could change it to look for a function named t, but I would have to change other parts of our system which are using gettext.

Furthermore, I think a function named t is more difficult/expensive/error prone to be looked up within source code...

@jamuhl jamuhl merged commit 3175f58 into i18next:master Aug 10, 2016
@jamuhl
Copy link
Member

jamuhl commented Aug 10, 2016

published [email protected]. thanks for providing this.

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

Successfully merging this pull request may close these issues.

2 participants