Skip to content

Commit

Permalink
Merge pull request #630 from isaachinman/master
Browse files Browse the repository at this point in the history
Replace NextJs example with link to next-i18next
  • Loading branch information
jamuhl committed Nov 29, 2018
2 parents b0a789b + edb0c99 commit 458d242
Show file tree
Hide file tree
Showing 22 changed files with 3 additions and 5,678 deletions.
74 changes: 3 additions & 71 deletions example/nextjs/README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,5 @@
[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/i18next/react-i18next/edit/master/example/nextjs)
# nextjs

# Internationalization with [react-i18next](https://github.com/i18next/react-i18next).
Implementing `react-i18next` with `next.js` is hard.

## How to use

### Download manually

Download the example [or clone the repo](https://github.com/i18next/react-i18next):

```bash
curl https://codeload.github.com/i18next/react-i18next/tar.gz/master | tar -xz --strip=2 react-i18next-master/example/nextjs
cd nextjs
```

Install it and run:

```bash
npm install
npm run dev
# or
yarn
yarn dev
```

Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))

```bash
now
```

### Testing the app

auto detecting user language: [http://localhost:3000](http://localhost:3000)

german: [http://localhost:3000/?lng=de](http://localhost:3000/?lng=de)

english: [http://localhost:3000/?lng=en](http://localhost:3000/?lng=en)

## The idea behind the example

This example app shows how to integrate [react-i18next](https://github.com/i18next/react-i18next) with [Next](https://github.com/zeit/next.js).

**Plus:**

- Routing and separating translations into multiple files (lazy load them on client routing)
- Child components (pure or using translation hoc)

### Features of this example app

- Server-side language negotiation
- Full control and usage of i18next on express server using [i18next-express-middleware](https://github.com/i18next/i18next-express-middleware) which asserts no async request collisions resulting in wrong language renderings
- Support for save missing features to get untranslated keys automatically created `locales/{lng}/{namespace}.missing.json` -> never miss to translate a key
- Proper pass down on translations via initialProps
- Taking advantage of multiple translation files including lazy loading on client (no need to load all translations upfront)
- Use express to also serve translations for clientside
- In contrast to react-intl the translations are visible both during development and in production
- you can use routes including /lng/ in url - disable it by setting enableSubpaths: false in config.js

### learn more

- [next.js](https://github.com/zeit/next.js)
- [react-i18next repository](https://github.com/i18next/react-i18next)
- [react-i18next documentation](https://react.i18next.com)

**Translation features:**

- [i18next repository](https://github.com/i18next/i18next)
- [i18next documentation](https://www.i18next.com)

**Translation management:**

- [locize](http://locize.com)
Because of this, we suggest using [next-i18next](https://github.com/isaachinman/next-i18next), a `next.js` plugin, in your projects.
45 changes: 0 additions & 45 deletions example/nextjs/components/Link.js

This file was deleted.

20 changes: 0 additions & 20 deletions example/nextjs/components/LocaleSwitcher.js

This file was deleted.

15 changes: 0 additions & 15 deletions example/nextjs/components/Navbar.js

This file was deleted.

56 changes: 0 additions & 56 deletions example/nextjs/config.js

This file was deleted.

39 changes: 0 additions & 39 deletions example/nextjs/i18n.js

This file was deleted.

12 changes: 0 additions & 12 deletions example/nextjs/lib/forceTrailingSlash.js

This file was deleted.

29 changes: 0 additions & 29 deletions example/nextjs/lib/lngPathCorrection.js

This file was deleted.

34 changes: 0 additions & 34 deletions example/nextjs/lib/lngPathDetector.js

This file was deleted.

25 changes: 0 additions & 25 deletions example/nextjs/lib/withNamespaces.js

This file was deleted.

26 changes: 0 additions & 26 deletions example/nextjs/package.json

This file was deleted.

Loading

0 comments on commit 458d242

Please sign in to comment.