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

Support defaultNS from I18nextProvider props #478

Merged
merged 2 commits into from Jul 18, 2018

Conversation

@iancw
Copy link
Contributor

iancw commented Jul 17, 2018

This allows the default namespace to be specified as a prop of
I18nextProvider. Previously namespace came from i18n instance option,
and then from arguments to the translate HOC. This allows the
translate HOC to be invoked without an explicit namespace, and the
parent I18nextProvider can define an alternate default namespace. This
allows sharing translated components without hard coding a defaultNS
at build time and without cloning multiple i18n instances to set
alternate namespaces.

e.g.

const Translated = translate()(Elem);

<I18nextProvider defaultNS="namespaceOne">
    <Translated />
</I18nextProvider>

<I18nextProvider defaultNS="namespaceTwo">
    <Translated />
</I18nextProvider>
This allows the default namespace to be specified as a prop of
`I18nextProvider`. Previously namespace came from i18n instance option,
and then from arguments to the `translate` HOC. This allows the
`translate` HOC to be invoked without an explicit namespace, and the
parent `I18nextProvider` can define an alternate default namespace. This
allows sharing `translate`d components without hard coding a defaultNS
at build time and without cloning multiple i18n instances to set
alternate namespaces.

e.g.

```
const Translated = translate()(Elem);

<I18nextProvider defaultNS="namespaceOne">
    <Translated />
</I18nextProvider>

<I18nextProvider defaultNS="namespaceTwo">
    <Translated />
</I18nextProvider>
```
@coveralls

This comment has been minimized.

Copy link

coveralls commented Jul 17, 2018

Coverage Status

Coverage increased (+0.1%) to 82.52% when pulling 4d9765b on iancw:default-ns-from-provider into 26ef680 on i18next:master.

@jamuhl jamuhl merged commit 57ebd2a into i18next:master Jul 18, 2018
3 checks passed
3 checks passed
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.1%) to 82.52%
Details
@jamuhl

This comment has been minimized.

Copy link
Member

jamuhl commented Jul 18, 2018

Awesome...published in react-i18next@7.9.0

@jamuhl

This comment has been minimized.

Copy link
Member

jamuhl commented Jul 18, 2018

Good addition - might be this is one of the last versions before breaking to use the new context API.

@iancw iancw deleted the iancw:default-ns-from-provider branch Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.