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

docs: prepare v13 #2018

Merged
merged 9 commits into from
Nov 14, 2022
Merged
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
46 changes: 32 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
## next
## 13.0.0

Although it is a major, existing code should not be impacted. Only the install.
Read also the [UPGRADING](https://github.com/i18next/next-i18next/blob/master/UPGRADING.md) document
to know more.
The v13.0.0 release is a major version to improve stability and general experience.
It comes with 2 easy changes related to installation. Existing code shouldn't be impacted.
Details can be found in the [UPGRADING.md](https://github.com/i18next/next-i18next/blob/master/UPGRADING.md#version-1300) document.

- **breaking**: react-i18next and i18next are now peer-dependencies and must be installed
in the consuming app, see [#1966](https://github.com/i18next/next-i18next/pull/1966)
### Breaking changes

- [react-i18next](https://github.com/i18next/react-i18next) and [i18next](https://github.com/i18next/i18next)
have been moved to peer-dependencies. They must be installed
in your app ([#1966](https://github.com/i18next/next-i18next/pull/1966))

```bash
# Add react-i18next > 12.0.0 and i18next > 22.0.4 to your app dependencies
npm install react-i18next i18next --save # NPM
yarn add react-i18next i18next # Yarn
pnpm add react-i18next i18next --save # PNPM
```

If you encounter any issue, please read the [Troubleshoot](https://github.com/i18next/next-i18next/blob/master/TROUBLESHOOT.md) doc.

- **breaking**: Types augmentation is now handled by i18next instead of react-i18next, see [#1997](https://github.com/i18next/next-i18next/pull/1997)
- **breaking**: Drop nextjs < 12.0.0 and react < 17.0.2 in [#1983](https://github.com/i18next/next-i18next/pull/1983)
- **breaking**: Drop node 12.x support, requires 14.x. Recommended minimum to `^14.13.1`,
see [#1974](https://github.com/i18next/next-i18next/pull/1974)
- **new:**: Upgrade to [i18next v22](https://github.com/i18next/i18next/releases) and react-i18next v12, see [#1966](https://github.com/i18next/next-i18next/pull/1966)
- **fix**: Fix types for appWithTranslation [#1987](https://github.com/i18next/next-i18next/pull/1987)
This might solve issues with duplicates and multiple i18n context instances.
If you encounter any issue, please read the [Troubleshoot](https://github.com/i18next/next-i18next/blob/master/TROUBLESHOOT.md#multiple-instances) doc
before posting an issue.


- Types augmentations are now handled by i18next instead of react-i18next ([#1997](https://github.com/i18next/next-i18next/pull/1997)).
See the upgrade [document here](https://github.com/i18next/next-i18next/blob/master/UPGRADING.md#keys-typings).

### New

- Support for NextJs 13 (excluding new experimental layout / rsc)
- Upgrade to [i18next v22](https://github.com/i18next/i18next/releases) and react-i18next v12, see [#1966](https://github.com/i18next/next-i18next/pull/1966)
- Support for node 18 lts [#2017](https://github.com/i18next/next-i18next/pull/2017)

### Fix

- Fix types for appWithTranslation [#1987](https://github.com/i18next/next-i18next/pull/1987)

### New minimum versions

We've dropped support for nextjs < 12.0.0 / react < 17.0.2 ([#1983](https://github.com/i18next/next-i18next/pull/1983))
and node < 14 ([#1974](https://github.com/i18next/next-i18next/pull/1974)).

## 12.1.0

Expand Down
62 changes: 56 additions & 6 deletions TROUBLESHOOT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
## Troubleshoot

### Can't find next-i18next.config.js
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrai that's a proposal

The goal is to help users:

  • monorepos and pnpm users (pnpm creates symlinks)

I'm not totally for this solution. I would prefer to make the config required, see also #2013. But that would be another BC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #1917 (comment)


When working in a monorepo or with a package manager that makes use of symlinks (ie pnpm),
you might experience the following issue:

```
(...)next-i18next/dist/commonjs/serverSideTranslations.js
Critical dependency: the request of a dependency is an expression
Cannot find module '(...)app/next-i18next.config.js'
```

As a workaround you can explicitly provide the configuration:

```tsx
// _app.tsx
import type { AppProps } from 'next/app'
import { appWithTranslation } from 'next-i18next'
import nextI18NextConfig from '../next-i18next.config.js'
const MyApp = ({ Component, pageProps }: AppProps) => (
<Component {...pageProps} />
)
export default appWithTranslation(MyApp, nextI18NextConfig)
```

For `getServerSideProps()` and `getStaticProps()` the recommended approach is
to wrap our `serverSideTranslations()` in a separate file where you can inject the
configuration.

```typescript
// ie: ./lib/i18n/getServerTranslations.ts
import type { SSRConfig, UserConfig } from 'next-i18next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import nextI18nextConfig from '../../next-i18next.config';

export const getServerTranslations = async (
locale: string,
namespacesRequired?: string[] | undefined,
configOverride?: UserConfig
): Promise<SSRConfig> => {
const config = configOverride ?? nextI18nextConfig;
return serverSideTranslations(locale, namespacesRequired, config);
};
```


### Multiple instances

The `next-i18next` / `react-i18next` packages are relying on a react context to
Expand All @@ -11,9 +56,14 @@ You will need to pass in an i18next instance by using initReactI18next
```

Before posting an issue, please ensure that you don't have duplicate versions of
`ì18next` and/or `react-i18next` installed.
`ì18next` and/or `react-i18next` installed. See [debug installation](#debug-installation)


Depending on you package manager you can list or fix duplicates by:
### Debug installation

Since v13.0.0, i18next and react-i18next must be installed in your app dependencies.
Some package managers might install them for you (auto install peer-deps). To avoid
install issues, please ensure i18next is `>=22.0.3` / next-i18next `>=12.0.0` and that you don't have duplicates:

| PM | Check | Fix (only on semver) |
|--------------|----------------------------------|---------------------------|
Expand All @@ -22,11 +72,11 @@ Depending on you package manager you can list or fix duplicates by:
| pnpm 7 | `npx -y pnpm-deduplicate --list` | `npx -y pnpm-deduplicate` |
| npm 8 | *not available* | `npm dedupe` |

Followed by an installation (or update). A new lock file should be generated.

Another way to list duplicate is to use `npm why -r next-i18next i18next`, `pnpm why -r next-i18next i18next`
Another way to list duplicate is to use `npm why -r next-i18next i18next`, `pnpm why -r next-i18next i18next`
or `yarn why -R next-i18next && yarn why -R i18next`.

If it does not fix the problem, search for similar issues and/or drop a new one (having versions helps to narrow possible causes)
After fixing potential duplicates, run an installation (or update). A new lock file should be generated.




2 changes: 1 addition & 1 deletion examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"nuke:install": "rimraf ./node_modules ./package-lock.json"
},
"dependencies": {
"i18next": "^22.0.4",
"i18next": "^22.0.5",
"next": "13.0.2",
"next-i18next": "file:../..",
"react": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/ssg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "rimraf .next out"
},
"dependencies": {
"i18next": "^22.0.3",
"i18next": "^22.0.5",
"next": "13.0.2",
"next-i18next": "file:../..",
"next-language-detector": "^1.0.2",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"gh-release": "6.0.4",
"husky": "^8.0.2",
"i18next": "^22.0.3",
"i18next": "^22.0.5",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"next": "^13.0.2",
Expand All @@ -133,7 +133,7 @@
"i18next-fs-backend": "^2.0.0"
},
"peerDependencies": {
"i18next": "^22.0.3",
"i18next": "^22.0.5",
"next": ">= 12.0.0",
"react": ">= 17.0.2",
"react-i18next": "^12.0.0"
Expand Down