Getting started
Installation
Install using npm
react-i18next can be added to your project using npm:
# npm
$ npm install react-i18next i18next --saveIn the /dist folder you find specific builds for commonjs, es6 modules,...
Load from CDN
You can also add a script tag to load react-i18next from one of the CDNs providing it, eg.:
unpkg.com
Translation "how to"
Official CLI
β i18next-cli
The official, high-performance, all-in-one command-line tool for i18next. It handles key extraction, code linting, locale syncing, and type generation. It's built with modern technologies for maximum speed and accuracy. This is the recommended tool for all i18next projects.
You have two options to translate your content:
Simple content
Simple content can easily be translated using the provided t function.
Before:
After:
JSX tree
Sometimes you might want to include html formatting or components like links into your translations. (Always try to get the best result for your translators - the final string to translate should be a complete sentence).
Before: Your react code would have looked something like:
After: With the trans component just change it to:
Basic sample
This basic sample tries to add i18n in a one file sample.
RESULT:

Do you like to read a more complete step by step tutorial?
Here you'll find a simple tutorial on how to best use react-i18next.
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.

Last updated