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

Add internationalization #68

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .linguirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"catalogs": [
{
"path": "<rootDir>/locales/{locale}/messages",
"include": "<rootDir>",
"exclude": [
"**/node_modules/**"
]
}
],
"format": "lingui",
"locales": ["en", "ro", "uk", "ru"],
"rootDir": "src",
"sourceLocale": "en"
}
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,46 @@ Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### Using lingui

1. Wrapping texts using `<Trans>` component.

```js
import { Trans } from "@lingui/macro";

<Trans>Hello world</Trans>;
```

2. Extracting messages

`npm run extract`

3. Add translations to `messages.json` for each language from the `locales` folder.

```json
// en/messages.json
{
"Știri oficiale": {
"translation": "Official news"
// ...
}
}

// ro/messages.json
{
"Știri oficiale": {
"translation": "Știri oficiale"
// ...
}
}
```

4. Compiling messages

`npm run compile`

See more details on the official lingui [page](https://lingui.js.org/tutorials/react.html)

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
Expand Down
Loading