Convert a Hard Coded String using react-intl FormattedMessage

Damon Bauer
InstructorDamon Bauer

Share this video with your friends

Send Tweet

In this lesson, we’ll replace hard coded strings with text from the user’s locale data, using the react-intl FormattedMessage component.

We'll also discuss the structure of the messages file, as well as use this utility from the react-intl documentation in order to keep our messages structured nicely.

~ 8 years ago

If your default langauge in the running browser is not 'en-US', 'es-ES', 'fr-FR' then an runtime error will happen. You need to add entry for the language e.g. for English, you need an entry 'en'.

Ashley Connor
Ashley Connor
~ 8 years ago

Couldn't you flatten the messages at build time? Seems like unnecessary computation for every client to be calling that function.

Etenne-Joseph Charles
Etenne-Joseph Charles
~ 7 years ago

How did you ever get three different browser windows to show in chrome in different languages ?