https://github.com/dmtrkovalenko/ns-react-18next
[Unmaintained] Namespaced i18next localization in react with no tears
https://github.com/dmtrkovalenko/ns-react-18next
context i18n i18next localization localized react typescript
Last synced: about 2 months ago
JSON representation
[Unmaintained] Namespaced i18next localization in react with no tears
- Host: GitHub
- URL: https://github.com/dmtrkovalenko/ns-react-18next
- Owner: dmtrKovalenko
- License: mit
- Created: 2018-06-22T14:23:07.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-29T10:22:06.000Z (over 6 years ago)
- Last Synced: 2025-04-29T23:39:33.514Z (2 months ago)
- Topics: context, i18n, i18next, localization, localized, react, typescript
- Language: TypeScript
- Homepage:
- Size: 198 KB
- Stars: 8
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NS react-i18next
[](https://www.npmjs.org/package/ns-react-i18next)
[](https://unpkg.com/[email protected]/index.amd.js)
[](https://codecov.io/gh/dmtrKovalenko/ns-react-18next)
[](https://travis-ci.org/dmtrKovalenko/ns-react-18next)
> Manage i18next namespaces with a power of react v16 context## Unmaintained
The purpose of this library was merged to official [react-i18next](https://github.com/i18next/react-i18next) at v9. So please use it. :)
### Installation
Available as npm package.
```sh
npm install ns-react-i18next
```Add global provider to the root of your app
```jsx
import * as i18n from 'i18next';
import { I18NextProvider } from 'ns-react-i18next'i18n
.use(LanguageDetector)
.init({
resources: translations,
fallbackLng: 'en',
debug: true,
defaultNS: 'common', // this namespace will be used if no namespace shared via context
fallbackNS: 'common',
});ReactDom.render(
,
document.getElementById('root')
)
```### Usage
Use another provider to share namespace between components sub-tree. Any `` component under this provider will render translated string of shared namespace + children string. Note that when the language will be changed (with a help of `i18n.changeLanguage()`) - every translate will rerender by itself.```jsx
import { Translate, NamespaceProvider } from 'ns-react-i18next'// specificNs:some_complex_structure
some_complex_structure
something_specific
// specificNs:something_specific```
Even possible to share namespace for several routes.
```jsx
```
There any `Translate` of CustomersList, ManageCustomer and thiers sub-components and sub-routes of take the 'customers' namespace.