react-i18next 12.3.0 → 13.0.0

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +1 -1
  3. package/TransWithoutContext.d.ts +26 -16
  4. package/dist/amd/react-i18next.js +827 -1104
  5. package/dist/amd/react-i18next.min.js +1 -1
  6. package/dist/commonjs/I18nextProvider.js +10 -13
  7. package/dist/commonjs/Trans.js +37 -52
  8. package/dist/commonjs/TransWithoutContext.js +130 -168
  9. package/dist/commonjs/Translation.js +8 -22
  10. package/dist/commonjs/context.js +45 -76
  11. package/dist/commonjs/defaults.js +7 -16
  12. package/dist/commonjs/i18nInstance.js +2 -4
  13. package/dist/commonjs/index.js +52 -86
  14. package/dist/commonjs/initReactI18next.js +2 -5
  15. package/dist/commonjs/unescape.js +4 -11
  16. package/dist/commonjs/useSSR.js +10 -14
  17. package/dist/commonjs/useTranslation.js +57 -79
  18. package/dist/commonjs/utils.js +38 -47
  19. package/dist/commonjs/withSSR.js +9 -23
  20. package/dist/commonjs/withTranslation.js +18 -45
  21. package/dist/es/I18nextProvider.js +10 -10
  22. package/dist/es/Trans.js +36 -43
  23. package/dist/es/TransWithoutContext.js +129 -159
  24. package/dist/es/Translation.js +7 -14
  25. package/dist/es/context.js +30 -50
  26. package/dist/es/defaults.js +7 -10
  27. package/dist/es/i18nInstance.js +1 -1
  28. package/dist/es/index.js +6 -18
  29. package/dist/es/initReactI18next.js +2 -2
  30. package/dist/es/package.json +1 -1
  31. package/dist/es/unescape.js +4 -10
  32. package/dist/es/useSSR.js +10 -11
  33. package/dist/es/useTranslation.js +58 -73
  34. package/dist/es/utils.js +34 -39
  35. package/dist/es/withSSR.js +9 -15
  36. package/dist/es/withTranslation.js +17 -35
  37. package/dist/umd/react-i18next.js +828 -1105
  38. package/dist/umd/react-i18next.min.js +1 -1
  39. package/helpers.d.ts +3 -0
  40. package/icu.macro.d.ts +37 -39
  41. package/index.d.ts +44 -37
  42. package/initReactI18next.d.ts +1 -1
  43. package/package.json +36 -36
  44. package/react-i18next.js +828 -1105
  45. package/react-i18next.min.js +1 -1
  46. package/src/useTranslation.js +17 -8
  47. package/src/utils.js +27 -15
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ### 13.0.0
2
+
3
+ - Update types to support t function redesign [1615](https://github.com/i18next/react-i18next/pull/1615)
4
+ - requires i18next >= v23.0.1
5
+
6
+ ### 12.3.1
7
+
8
+ - optimization for optional lng prop for useTranslation, should now prevent missings when lazy loading translations [1637](https://github.com/i18next/react-i18next/issues/1637)
9
+
1
10
  ### 12.3.0
2
11
 
3
12
  - optional lng prop for useTranslation (helping on server side [1637](https://github.com/i18next/react-i18next/issues/1637))
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 i18next
3
+ Copyright (c) 2023 i18next
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,33 +1,43 @@
1
- import { i18n, TFuncKey, Namespace, TypeOptions, TFunction, KeyPrefix } from 'i18next';
1
+ import type {
2
+ i18n,
3
+ ParseKeys,
4
+ Namespace,
5
+ TypeOptions,
6
+ TOptions,
7
+ TFunction,
8
+ KeyPrefix,
9
+ } from 'i18next';
2
10
  import * as React from 'react';
3
11
 
4
- type DefaultNamespace = TypeOptions['defaultNS'];
12
+ type _DefaultNamespace = TypeOptions['defaultNS'];
5
13
 
6
14
  type TransChild = React.ReactNode | Record<string, unknown>;
7
15
  export type TransProps<
8
- K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
9
- N extends Namespace = DefaultNamespace,
10
- TKPrefix = undefined,
11
- E = React.HTMLProps<HTMLDivElement>
16
+ Key extends ParseKeys<Ns, TOpt, KPrefix>,
17
+ Ns extends Namespace = _DefaultNamespace,
18
+ TOpt extends TOptions = {},
19
+ KPrefix = undefined,
20
+ E = React.HTMLProps<HTMLDivElement>,
12
21
  > = E & {
13
- children?: TransChild | TransChild[];
22
+ children?: TransChild | readonly TransChild[];
14
23
  components?: readonly React.ReactElement[] | { readonly [tagName: string]: React.ReactElement };
15
24
  count?: number;
16
25
  context?: string;
17
26
  defaults?: string;
18
27
  i18n?: i18n;
19
- i18nKey?: K | K[];
20
- ns?: N;
28
+ i18nKey?: Key | Key[];
29
+ ns?: Ns;
21
30
  parent?: string | React.ComponentType<any> | null; // used in React.createElement if not null
22
- tOptions?: {};
31
+ tOptions?: TOpt;
23
32
  values?: {};
24
33
  shouldUnescape?: boolean;
25
- t?: TFunction<N, TKPrefix>;
34
+ t?: TFunction<Ns, KPrefix>;
26
35
  };
27
36
 
28
37
  export function Trans<
29
- K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
30
- N extends Namespace = DefaultNamespace,
31
- TKPrefix extends KeyPrefix<N> = undefined,
32
- E = React.HTMLProps<HTMLDivElement>
33
- >(props: TransProps<K, N, TKPrefix, E>): React.ReactElement;
38
+ Key extends ParseKeys<Ns, TOpt, KPrefix>,
39
+ Ns extends Namespace = _DefaultNamespace,
40
+ TOpt extends TOptions = {},
41
+ KPrefix extends KeyPrefix<Ns> = undefined,
42
+ E = React.HTMLProps<HTMLDivElement>,
43
+ >(props: TransProps<Key, Ns, TOpt, KPrefix, E>): React.ReactElement;