taxonomy-editor icon indicating copy to clipboard operation
taxonomy-editor copied to clipboard

Setup i18n in the project

Open alexgarel opened this issue 3 years ago • 2 comments

What

  • We have to setup i18n in the react application in a way which is compatible with Crowdin.

Part of

  • #30

alexgarel avatar Sep 06 '22 16:09 alexgarel

@alexfauquette can you tell us, how it's setup in hungergames ?

alexgarel avatar Sep 06 '22 16:09 alexgarel

Of course

About crowding

You have a github action to keep it up to date here

You can copy past the folder structure (i18n folder) which contains common.json and after 1 file per locale

About React

I used reacti18n. You can have a look to the get started

Configuration

I've one file that do the initialization on the all app

It's called in the root index.js as follow

import "./i18n";

Using it

After that all your components can have translation as follow:

import { useTranslation } from "react-i18next";

const MyComponent = ()=>{
	const { t } = useTranslation();
	
	return <p>{t('myTrabslationKey')}</p>
}

alexfauquette avatar Sep 07 '22 08:09 alexfauquette