Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup i18n in the project #70

Open
alexgarel opened this issue Sep 6, 2022 · 2 comments
Open

Setup i18n in the project #70

alexgarel opened this issue Sep 6, 2022 · 2 comments

Comments

@alexgarel
Copy link
Member

alexgarel commented Sep 6, 2022

What

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

Part of

@alexgarel alexgarel changed the title setup i18n in the project Setup i18n in the project Sep 6, 2022
@alexgarel
Copy link
Member Author

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

@alexfauquette
Copy link
Member

alexfauquette commented Sep 7, 2022

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>
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants