DEV Community

How to translate your React.js app with i18next

Oksana Ivanchenko on May 03, 2019

Today, I will show you how to translate the text and date in your React.js application. First of all, you must install some dependencies: yarn ...
Collapse
 
tonixtuft profile image
Anton Bagdatyev (Tonix-Tuft)

Thank you for your article Oksana!

How do you manage the fact that translations files may be cached by the browser and therefore if you publish an updated translation file, let's say public/locales/ru/translation.json, the browser may still continue to use an outdated cached version of public/locales/ru/translation.json.

Did you find a solution for that as well?

Collapse
 
superturbis profile image
Super Turbo • Edited

Hi Oksana! Great solution, thank you! I'd like to ask you about an issue I have whenever I run it...

It outputs a red screen, with white fonts and the following error:

“A React component suspended while rendering, but no fallback UI was specified. Add a component higher in the tree to provide a loading indicator or placeholder to display”

I don't understand where does it come from, since the <Suspense/> component has already been filled with the fallback:

const Loader = () => {
  return <div>loading...</div>
};
export default props => {
    return (
        <Suspense fallback={<Loader />}>
        ...
        </Suspense>
    )
}

Thank you in advance Oksana!

Collapse
 
fkirc profile image
Felix K

Thank you for the summary. I found that those i18n-libraries are not enough to keep translation-files in sync, which is why I wrote "attranslate" as an additional tool for file-synchronization: github.com/fkirc/attranslate you can give it a try if you are seeking a free solution

Collapse
 
gtobar profile image
Guillermo Tobar

Thanks for sharing the post, its content is very valuable.

Collapse
 
kilofafeure profile image
kilofafeure

Beginner web developer? I've read a lot of solutions for i18next and you have been the only one that has made my app be translated correctly, all very clear. You are agoddess!!! Thanks a lot!!!

Collapse
 
ksushiva profile image
Oksana Ivanchenko

Wow! Thanks for your comment! I’m very happy that you found this article helpful

Collapse
 
burzumumbra profile image
Ronald Flores Sequeira

Cool, now I have something to play with on the weekend.

Collapse
 
etainlove profile image
RemeberIamLove

Thank you Oksana! It works like a charm!

Collapse
 
ahmetcetin profile image
Ahmet Cetin

The simplest just to the point explanation I've seen so far about i18next. Thx a lot for sharing this. i18next should put this article in their website as Getting Started.

Collapse
 
adrai profile image
Adriano Raiano

i18next-xhr-backend is deprecated, i18next-http-backend can be used now.

i.e. dev.to/adrai/how-to-properly-inter...

Collapse
 
jericfarias profile image
Eric Farias

It works fine with props? I mean suppose I have a header component that receive a prop title to render some things like this.

Collapse
 
duongynguyen profile image
Nguyen Duong

I read and integrated follow i18next documents but my project failed. Since I read your post and follow it, I very surprise. I got it. You are my idol. Thank you so much!

Collapse
 
trejocode profile image
Sergio A. Trejo

Thank you, for me es better i18n than react-intl, works fine and it's super easy to config

Collapse
 
kanags91 profile image
Kanagaraj Palanisamy

Wonderful. Able to set up our entire app in just a week..!! Thanks a lot :)

Collapse
 
hd4ng profile image
Huy Dang

Thanks Oksana, nice article. Could you explain why locales should be placed in the public folder? Thanks