Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

README.md 9.5 KiB

il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. [![CircleCI](https://circleci.com/gh/i18next/react-i18next.svg?style=svg)](https://circleci.com/gh/i18next/react-i18next)
  3. [![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/i18next/react-i18next)
  4. [![Coverage Status](https://coveralls.io/repos/github/i18next/react-i18next/badge.svg)](https://coveralls.io/github/i18next/react-i18next)
  5. [![Quality][quality-badge] ][quality-url]
  6. [![dependencies][dependencies-image] ][dependencies-url]
  7. [![devdependencies][devdependencies-image] ][devdependencies-url]
  8. [npm-icon]: https://nodei.co/npm/react-i18next.png?downloads=true
  9. [npm-url]: https://npmjs.org/package/react-i18next
  10. [dependencies-image]: https://david-dm.org/i18next/react-i18next.png
  11. [dependencies-url]: https://david-dm.org/i18next/react-i18next
  12. [devdependencies-image]: https://david-dm.org/i18next/react-i18next/dev-status.png
  13. [devdependencies-url]: https://david-dm.org/i18next/react-i18next#info=devDependencies
  14. [quality-badge]: http://npm.packagequality.com/shield/react-i18next.svg
  15. [quality-url]: http://packagequality.com/#?package=react-i18next
  16. ### IMPORTANT:
  17. Master Branch is the new v10 using hooks.
  18. ```bash
  19. $ v10.0.0
  20. npm i react-i18next
  21. ```
  22. **react-native: not yet supports hooks (hooks are part of react-native v0.59.0)!!!**
  23. For the legacy version please use the [v9.x.x Branch](https://github.com/i18next/react-i18next/tree/v9.x.x)
  24. ```bash
  25. $ v9.0.10 (legacy)
  26. npm i react-i18next@legacy
  27. ```
  28. ### Documentation
  29. The documentation is published on [react.i18next.com](https://react.i18next.com)
  30. ### What will my code look like?
  31. **Before:** Your react code would have looked something like:
  32. ```jsx
  33. ...
  34. <div>Just simple content</div>
  35. <div>
  36. Hello <strong title="this is your name">{name}</strong>, you have {count} unread message(s). <Link to="/msgs">Go to messages</Link>.
  37. </div>
  38. ...
  39. ```
  40. **After:** With the trans component just change it to:
  41. ```jsx
  42. ...
  43. <div>{t('simpleContent')}</div>
  44. <Trans i18nKey="userMessagesUnread" count={count}>
  45. Hello <strong title={t('nameTitle')}>{{name}}</strong>, you have {{count}} unread message. <Link to="/msgs">Go to messages</Link>.
  46. </Trans>
  47. ...
  48. ```
  49. Head over to the **interactive playground** at [codesandbox](https://codesandbox.io/s/1zxox032q).
  50. ### 📖 What others say
  51. - [I18n with React and i18next](https://alligator.io/react/i18n-with-react-and-i18next) via Alligator.io by Danny Hurlburt
  52. - [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
  53. - [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
  54. - [Using i18next to translate React.js application](https://codetain.co/2018/05/using-i18next-to-translate-reactjs-application/) via codetain.co by Kasia Dadek
  55. - [Building i18n with Gatsby](https://www.gatsbyjs.org/blog/2017-10-17-building-i18n-with-gatsby/) via gatsbyjs.org by Samuel Goudie
  56. - [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
  57. - [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
  58. - you're welcome to share your story...
  59. ### Why i18next?
  60. - **Simplicity:** no need to change your webpack configuration or adding additional babel transpilers, just use create-react-app and go
  61. - **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**.
  62. - **Beyond i18n** comes with [locize](https://locize.com) bridging the gap between developement and translations - covering the whole translation process.
  63. <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">
  64. ### Localization workflow
  65. Want to learn more about how seamless your internationalization and translation process can be?
  66. [![video](example/v9.x.x/locize/video_sample.png)](https://www.youtube.com/watch?v=9NOzJhgmyQE)
  67. [watch the video](https://www.youtube.com/watch?v=9NOzJhgmyQE)
  68. ### Installation
  69. Source 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.
  70. ```
  71. # npm package
  72. $ npm install react-i18next
  73. ```
  74. - If you don't use a module loader it will be added to `window.reactI18next`
  75. ### Examples
  76. - [Example react](https://github.com/i18next/react-i18next/tree/master/example/react)
  77. #### v9 samples
  78. - [Example react](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/react)
  79. - [Example preact](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/preact)
  80. - [Example react-native](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/reactnative-expo)
  81. - [Example expo.io](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/reactnative-expo)
  82. - [Example next.js](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/nextjs)
  83. - [Example razzle](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/razzle-ssr)
  84. - [Example hashbase / beaker browser](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/dat)
  85. - [Example storybook](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/storybook)
  86. - [Example locize.com](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/locize-example)
  87. - [Example test with jest](https://github.com/i18next/react-i18next/tree/master/example/v9.x.x/test-jest)
  88. ### Requirements
  89. - react >= **16.8.0**
  90. - react-dom >= **16.8.0**
  91. - react-native >= **0.59.0**
  92. - i18next >= **10.0.0** (typescript users: >=17.0.9)
  93. #### v9
  94. - react >= **0.14.0** (in case of < v16 or preact you will need to define parent in [Trans component](https://react.i18next.com/legacy-v9/trans-component#trans-props) or globally in [i18next.react options](https://react.i18next.com/legacy-v9/trans-component#additional-options-on-i-18-next-init))
  95. - i18next >= **2.0.0**
  96. ## Core Contributors
  97. Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):
  98. <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
  99. <!-- prettier-ignore -->
  100. | [<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") |
  101. | :---: | :---: | :---: | :---: | :---: |
  102. <!-- ALL-CONTRIBUTORS-LIST:END -->
  103. This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
  104. ---
  105. <h3 align="center">Gold Sponsors</h3>
  106. <p align="center">
  107. <a href="https://locize.com/" target="_blank">
  108. <img src="https://raw.githubusercontent.com/i18next/i18next/master/assets/locize_sponsor_240.gif" width="240px">
  109. </a>
  110. </p>
  111. ---
  112. **localization as a service - locize.com**
  113. Needing a translation management? Want to edit your translations with an InContext Editor? Use the orginal provided to you by the maintainers of i18next!
  114. ![locize](https://locize.com/img/ads/github_locize.png)
  115. With using [locize](http://locize.com/?utm_source=react_i18next_readme&utm_medium=github) you directly support the future of i18next and react-i18next.
  116. ---