https://github.com/iamdevvalecha/with-lingui
https://github.com/iamdevvalecha/with-lingui
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/iamdevvalecha/with-lingui
- Owner: iamdevvalecha
- Created: 2021-04-14T17:49:35.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-14T17:49:43.000Z (about 5 years ago)
- Last Synced: 2026-01-03T16:24:00.137Z (3 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# With Lingui example
This example shows a way to use [lingui.js](https://lingui.js.org) with next.js.
It adds a webpack loader for the messages to avoid having to manually compile while developing as well as adds the compile step to the `next build` script for production builds.
The example also uses a Higher order Component which can be added to all pages which will be translated and that checks for a `?lang` query string switch the language. Next.js will dynamically load in the messages for the locale when navigating using a Next.js `` component.
## Deploy your own
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
[](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-lingui&project-name=with-lingui&repository-name=with-lingui)
## How to use
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:
```bash
npx create-next-app --example with-lingui with-lingui-app
# or
yarn create next-app --example with-lingui with-lingui-app
```
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
### How to add more translated strings
To add new strings use the [react component](https://lingui.js.org/tutorials/react-patterns.html#common-i18n-patterns-in-react) `` and then run `yarn export` to export the messages into `locale/{language}/messages.po`.
### How to add another language
To add another language simply run `yarn add-locale ` and it will create a new locale in the `locale/messages/` directory.