UNPKG

9.65 kBMarkdownView Raw
1# react-i18next [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Awesome%20react-i18next%20for%20react.js%20based%20on%20i18next%20internationalization%20ecosystem%20&url=https://github.com/i18next/react-i18next&via=jamuhl&hashtags=i18n,reactjs,js,dev)
2
3[![CircleCI](https://circleci.com/gh/i18next/react-i18next.svg?style=svg)](https://circleci.com/gh/i18next/react-i18next)
4[![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/i18next/react-i18next)
5[![Coverage Status](https://coveralls.io/repos/github/i18next/react-i18next/badge.svg)](https://coveralls.io/github/i18next/react-i18next)
6[![Quality][quality-badge] ][quality-url]
7[![dependencies][dependencies-image] ][dependencies-url]
8[![devdependencies][devdependencies-image] ][devdependencies-url]
9
10[npm-icon]: https://nodei.co/npm/react-i18next.png?downloads=true
11[npm-url]: https://npmjs.org/package/react-i18next
12[dependencies-image]: https://david-dm.org/i18next/react-i18next.png
13[dependencies-url]: https://david-dm.org/i18next/react-i18next
14[devdependencies-image]: https://david-dm.org/i18next/react-i18next/dev-status.png
15[devdependencies-url]: https://david-dm.org/i18next/react-i18next#info=devDependencies
16[quality-badge]: http://npm.packagequality.com/shield/react-i18next.svg
17[quality-url]: http://packagequality.com/#?package=react-i18next
18
19### IMPORTANT:
20
21Master Branch is the new v10 using hooks.
22
23```bash
24$ v10.0.0
25npm i react-i18next
26```
27
28**react-native: not yet supports hooks (hooks are part of react-native v0.59.0)!!!**
29
30For the legacy version please use the [v9.x.x Branch](https://github.com/i18next/react-i18next/tree/v9.x.x)
31
32```bash
33$ v9.0.10 (legacy)
34npm i react-i18next@legacy
35```
36
37### Documentation
38
39The documentation is published on [react.i18next.com](https://react.i18next.com)
40
41### How will my code look like?
42
43**Before:** Your react code would have looked something like:
44
45```jsx
46...
47<div>Just simple content</div>
48<div>
49 Hello <strong title="this is your name">{name}</strong>, you have {count} unread message(s). <Link to="/msgs">Go to messages</Link>.
50</div>
51...
52```
53
54**After:** With the trans component just change it to:
55
56```jsx
57...
58<div>{t('simpleContent')}</div>
59<Trans i18nKey="userMessagesUnread" count={count}>
60 Hello <strong title={t('nameTitle')}>{{name}}</strong>, you have {{count}} unread message. <Link to="/msgs">Go to messages</Link>.
61</Trans>
62...
63```
64
65Head over to the **interactive playground** at [codesandbox](https://codesandbox.io/s/1zxox032q).
66
67### 📖 What others say
68
69- [I18n with React and i18next](https://alligator.io/react/i18n-with-react-and-i18next) via Alligator.io by Danny Hurlburt
70- [Ultimate Localization of React (Mobx) App with i18next](https://itnext.io/ultimate-localization-of-react-mobx-app-with-i18next-efab77712149) via itnext.io by Viktor Shevchenko
71- [Internationalization for react done right Using the i18next i18n ecosystem](https://reactjsexample.com/internationalization-for-react-done-right-using-the-i18next-i18n-ecosystem/) via reactjsexample.com
72- [Using i18next to translate React.js application](https://codetain.co/2018/05/using-i18next-to-translate-reactjs-application/) via codetain.co by Kasia Dadek
73- [Building i18n with Gatsby](https://www.gatsbyjs.org/blog/2017-10-17-building-i18n-with-gatsby/) via gatsbyjs.org by Samuel Goudie
74- [Get your react.js application translated with style](https://medium.com/@jamuhl/get-your-react-js-application-translated-with-style-4ad090aefc2c) by Jan Mühlemann
75- [Translate your expo.io / react-native mobile application](https://medium.com/@jamuhl/translate-your-expo-io-react-native-mobile-application-aa220b2362d2) by Jan Mühlemann
76- you're welcome to share your story...
77
78### Why i18next?
79
80- **Simplicity:** no need to change your webpack configuration or adding additional babel transpilers, just use create-react-app and go
81- **Production ready** we know there are more needs for production than just doing i18n on the clientside. So we offer wider support on [serverside](https://www.i18next.com/supported-frameworks.html) too (nodejs, php, ruby, .net, ...). **Learn once - translate everywhere**.
82- **Beyond i18n** comes with [locize](https://locize.com) bridging the gap between developement and translations - covering the whole translation process.
83
84<img src="https://blobscdn.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-L9iS6Wm2hynS5H9Gj7j%2F-L9iS7LlT2W7wFtJH-2n%2F-L9iSBP9U65-bHJBRSDv%2Fi18next-ecosystem.jpg?generation=1523345318122913&alt=media" alt="i18next ecossystem" width="400">
85
86### Localization workflow
87
88Want to learn more about how seamless your internationalization and translation process can be?
89
90[![video](example/v9.x.x/locize/video_sample.png)](https://www.youtube.com/watch?v=9NOzJhgmyQE)
91
92[watch the video](https://www.youtube.com/watch?v=9NOzJhgmyQE)
93
94### Installation
95
96Source can be loaded via [npm](https://www.npmjs.com/package/react-i18next) or [downloaded](https://github.com/i18next/react-i18next/blob/master/react-i18next.min.js) from this repo.
97
98```
99# npm package
100$ npm install react-i18next
101```
102
103- If you don't use a module loader it will be added to `window.reactI18next`
104
105### Examples
106
107- [Example react](https://github.com/i18next/react-i18next/tree/master/example/react)
108
109#### v9 samples
110
111- [Example react](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/react)
112- [Example preact](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/preact)
113- [Example react-native](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/reactnative-expo)
114- [Example expo.io](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/reactnative-expo)
115- [Example next.js](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/nextjs)
116- [Example razzle](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/razzle-ssr)
117- [Example hashbase / beaker browser](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/dat)
118- [Example storybook](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/storybook)
119- [Example locize.com](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/locize-example)
120- [Example test with jest](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/test-jest)
121
122### Requirements
123
124- react >= **16.8.0**
125- react-native >= **0.59.0**
126- i18next >= **10.0.0**
127
128#### v9
129
130- react >= **0.14.0** (in case of < v16 or preact you will need to define parent in [Trans component](https://react.i18next.com/components/trans-component.html#props) or globally in [i18next.react options](https://react.i18next.com/components/trans-component.html#additional-options-on-i18nextinit))
131- i18next >= **2.0.0**
132
133## Core Contributors
134
135Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
136
137<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
138<!-- prettier-ignore -->
139| [<img src="https://avatars3.githubusercontent.com/u/977772?v=4" width="100px;"/><br /><sub><b>Jan Mühlemann</b></sub>](http://twitter.com/jamuhl)<br />[💻](https://github.com/i18next/react-i18next/commits?author=jamuhl "Code") [💡](#example-jamuhl "Examples") [📖](https://github.com/i18next/react-i18next/commits?author=jamuhl "Documentation") [💬](#question-jamuhl "Answering Questions") | [<img src="https://avatars0.githubusercontent.com/u/1086194?v=4" width="100px;"/><br /><sub><b>Adriano Raiano</b></sub>](http://twitter.com/#!/adrirai)<br />[💻](https://github.com/i18next/react-i18next/commits?author=adrai "Code") [💡](#example-adrai "Examples") [📖](https://github.com/i18next/react-i18next/commits?author=adrai "Documentation") [💬](#question-adrai "Answering Questions") | [<img src="https://avatars1.githubusercontent.com/u/10575782?v=4" width="100px;"/><br /><sub><b>Isaac Hinman</b></sub>](https://isaachinman.com)<br />[💻](https://github.com/i18next/react-i18next/commits?author=isaachinman "Code") [💡](#example-isaachinman "Examples") [💬](#question-isaachinman "Answering Questions") | [<img src="https://avatars1.githubusercontent.com/u/136564?v=4" width="100px;"/><br /><sub><b>Kevin Ross</b></sub>](http://www.alienfast.com)<br />[💬](#question-rosskevin "Answering Questions") [💻](https://github.com/i18next/react-i18next/commits?author=rosskevin "Code") | [<img src="https://avatars0.githubusercontent.com/u/7825467?v=4" width="100px;"/><br /><sub><b>Matheus Schettino</b></sub>](https://github.com/schettino)<br />[💻](https://github.com/i18next/react-i18next/commits?author=schettino "Code") [💬](#question-schettino "Answering Questions") |
140| :---: | :---: | :---: | :---: | :---: |
141
142<!-- ALL-CONTRIBUTORS-LIST:END -->
143
144This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
145
146---
147
148<h3 align="center">Gold Sponsors</h3>
149
150<p align="center">
151 <a href="https://locize.com/" target="_blank">
152 <img src="https://raw.githubusercontent.com/i18next/i18next/master/assets/locize_sponsor_240.gif" width="240px">
153 </a>
154</p>
155
156---
157
158**localization as a service - locize.com**
159
160Needing a translation management? Want to edit your translations with an InContext Editor? Use the orginal provided to you by the maintainers of i18next!
161
162![locize](https://locize.com/img/ads/github_locize.png)
163
164With using [locize](http://locize.com/?utm_source=react_i18next_readme&utm_medium=github) you directly support the future of i18next and react-i18next.
165
166---