Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

localization in react.js suggestions and example

Tags:

reactjs

We're on the decision on where to go on localization in react.js, surely there are ways to doing localization, but what would be your recommendation?

I tried yahoo's react-intl but to no avail:

var ReactIntl = require('react-intl') // we did npm install react-intl
// somewhere in the react component
render: function() {
    return (<div><ReactIntl.Number>{600}</ReactIntl.Number></div>);
}

gives the error: Cannot read property '_mockedReactClassConstructor' of undefined

spent few hours try to resolve this error, still can't resolve -> give up

I tried l20n by mozilla but not sure if it'll work with react.js

wondering what would you suggest for react.js localization, thanks!

like image 926
Jim Avatar asked Dec 30 '14 09:12

Jim


People also ask

What is localize React?

Localization (also referred to as i10n) is the process of adapting the website/application to a specific locale/region. Translation of text is only one of several elements in the localization process. Translating a bunch of sentences might seem very easy and intuitive.

How do you use localization in JavaScript?

There are two ways to go at JavaScript localization: File-based: Meaning that you extract your content in the form of a file, upload it to the Translation Management System (TMS), translate the content, then download it from the TMS and upload it back to your app/website and deploy the changes.

What is the difference between internationalization and localization?

Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting internationalized software for a specific region or language by translating text and adding locale-specific components.


1 Answers

in response to my question. we decided not to use yahoo's react-intl but use i18next instead. Considering using something more stable and popular for our production is important.

what you can do is to initialize i18next at the root of your page, and pass that down through props. Do use a state to prevent page rendering before i18next is initialized.

like image 125
Jim Avatar answered Oct 22 '22 03:10

Jim