react-i18next 17.0.8 → 17.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 17.0.9
2
+
3
+ - fix: allow TypeScript 7 in the optional `typescript` peer dependency range (`^5 || ^6 || ^7`). With `typescript@7.0.2` in a project, `npm install` failed with an `ERESOLVE` peer conflict. Fixes [#1927](https://github.com/i18next/react-i18next/issues/1927), thanks @andikapradanaarif.
4
+ - fix(types): `<Trans t={t} ns="ns" …>` with a `t` from `useTranslation(['ns'])` now typechecks under TypeScript 7. TS7 intersects the `Ns` inference candidates coming from the `t` prop (`readonly ['ns']`) and the `ns` prop (`'ns'`) into an unsatisfiable `'ns' & readonly ['ns']`, where TS6 resolved them. The `ns` prop on `TransProps`, `TransSelectorProps` and `IcuTransWithoutContextProps` now also accepts a single namespace out of an array-typed `Ns` (`Ns | (Ns extends readonly (infer S extends string)[] ? S : never)`) — which matches runtime behavior and is unchanged under TS5/TS6.
5
+
1
6
  ## 17.0.8
2
7
 
3
8
  - fix(types): `<Trans i18nKey={$ => ...}>` now typechecks under `enableSelector: 'strict'`. The `Trans` component's conditional type was gated on `_EnableSelector extends true | 'optimize'`, excluding `'strict'` and falling back to the legacy string-key signature. Runtime was already correct (it calls `keyFromSelector(i18nKey)` whenever `typeof i18nKey === 'function'`); this is a type-only fix that widens the conditional to include `'strict'`. Thanks @Faithfinder ([#1921](https://github.com/i18next/react-i18next/pull/1921))
package/README.md CHANGED
@@ -33,6 +33,8 @@ npm i react-i18next@legacy
33
33
 
34
34
  If you don't like to manage your translation files manually or are simply looking for a [better management solution](https://www.locize.com?utm_source=react_i18next_readme&utm_medium=github&utm_campaign=readme), take a look at [i18next-locize-backend](https://github.com/locize/i18next-locize-backend). The i18next [backend plugin](https://www.i18next.com/overview/plugins-and-utils#backends) for 🌐 [Locize](https://www.locize.com?utm_source=react_i18next_readme&utm_medium=github&utm_campaign=readme) ☁️ — built by the same team behind react-i18next, with CDN delivery, AI translation, and no redeploys for copy changes.
35
35
 
36
+ Starting from a React app with hardcoded strings (e.g. generated with v0, Lovable or Cursor)? Run `npx i18next-cli localize` — one command that wraps strings in `t()`, extracts keys, connects to [Locize](https://www.locize.com?from=react-i18next_readme__localize) and AI-translates your app. See the [launch post](https://www.locize.com/blog/i18next-cli-localize?from=react-i18next_readme__localize).
37
+
36
38
  ### Documentation
37
39
 
38
40
  The documentation is published on [react.i18next.com](https://react.i18next.com) and PR changes can be supplied [here](https://github.com/i18next/react-i18next-gitbook).
@@ -42,7 +42,9 @@ export type TransProps<
42
42
  defaults?: string;
43
43
  i18n?: i18n;
44
44
  i18nKey?: Key | Key[];
45
- ns?: Ns;
45
+ // allow a single namespace from an array-typed `t` (e.g. useTranslation(['ns'])); TS7 intersects
46
+ // inference candidates from `t` and `ns`, so a bare `Ns` here rejects ns="ns" when t is passed
47
+ ns?: Ns | (Ns extends readonly (infer S extends string)[] ? S : never);
46
48
  parent?: string | React.ComponentType<any> | null; // used in React.createElement if not null
47
49
  tOptions?: TOpt;
48
50
  values?: InterpolationMap<Ret>;
@@ -82,7 +84,8 @@ export interface TransSelectorProps<
82
84
  defaults?: string | Key;
83
85
  i18n?: i18n;
84
86
  i18nKey?: Key | readonly Key[];
85
- ns?: Ns;
87
+ // see TransProps.ns: keep single-namespace values assignable when `t` fixes Ns to an array
88
+ ns?: Ns | (Ns extends readonly (infer S extends string)[] ? S : never);
86
89
  parent?: string | React.ComponentType<any> | null; // used in React.createElement if not null
87
90
  tOptions?: TOpt;
88
91
  values?: Key extends (...args: any[]) => infer R ? InterpolationMap<R> : {};
@@ -1 +1 @@
1
- {"type":"module","version":"17.0.8"}
1
+ {"type":"module","version":"17.0.9"}
package/index.d.ts CHANGED
@@ -62,7 +62,8 @@ export type IcuTransWithoutContextProps<
62
62
  /** Declaration tree describing React components and their props */
63
63
  content: IcuTransContentDeclaration[];
64
64
  /** Optional namespace(s) for the translation */
65
- ns?: Ns;
65
+ // see TransProps.ns: keep single-namespace values assignable when `t` fixes Ns to an array
66
+ ns?: Ns | (Ns extends readonly (infer S extends string)[] ? S : never);
66
67
  /** Optional values for ICU variable interpolation */
67
68
  values?: Record<string, any>;
68
69
  /** i18next instance. If not provided, uses global instance */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-i18next",
3
- "version": "17.0.8",
3
+ "version": "17.0.9",
4
4
  "description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "types": "./index.d.mts",
@@ -74,7 +74,7 @@
74
74
  "peerDependencies": {
75
75
  "i18next": ">= 26.2.0",
76
76
  "react": ">= 16.8.0",
77
- "typescript": "^5 || ^6"
77
+ "typescript": "^5 || ^6 || ^7"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "react-dom": {