Socket
Socket
Sign inDemoInstall

react-i18next

Package Overview
Dependencies
Maintainers
2
Versions
313
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-i18next - npm Package Compare versions

Comparing version 11.14.1 to 11.14.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

### 11.14.2
- Add type-safe support to deep keyPrefix [1403](https://github.com/i18next/react-i18next/pull/1403)
### 11.14.1

@@ -2,0 +6,0 @@

2

package.json
{
"name": "react-i18next",
"version": "11.14.1",
"version": "11.14.2",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",

@@ -5,0 +5,0 @@ "main": "dist/commonjs/index.js",

@@ -105,11 +105,14 @@ import i18next, {

// Normalize single namespace
type AppendKeys<K1, K2, S extends string = TypeOptions['keySeparator']> = `${K1 & string}${S}${K2 &
string}`;
type AppendKeys2<K1, K2, S extends string = TypeOptions['keySeparator']> = `${K1 &
string}${S}${Exclude<K2, keyof any[]> & string}`;
export type KeysWithSeparator<K1, K2, S extends string = TypeOptions['keySeparator']> = `${K1 &
string}${S}${K2 & string}`;
type KeysWithSeparator2<K1, K2> = KeysWithSeparator<K1, Exclude<K2, keyof any[]>>;
type Normalize2<T, K = keyof T> = K extends keyof T
? T[K] extends Record<string, any>
? T[K] extends readonly any[]
? AppendKeys2<K, WithOrWithoutPlural<keyof T[K]>> | AppendKeys2<K, Normalize2<T[K]>>
: AppendKeys<K, WithOrWithoutPlural<keyof T[K]>> | AppendKeys<K, Normalize2<T[K]>>
?
| KeysWithSeparator2<K, WithOrWithoutPlural<keyof T[K]>>
| KeysWithSeparator2<K, Normalize2<T[K]>>
:
| KeysWithSeparator<K, WithOrWithoutPlural<keyof T[K]>>
| KeysWithSeparator<K, Normalize2<T[K]>>
: never

@@ -171,4 +174,18 @@ : never;

type NormalizeWithKeyPrefix<
T,
K,
S extends string = TypeOptions['keySeparator']
> = K extends `${infer K1}${S}${infer K2}`
? K1 extends keyof T
? NormalizeWithKeyPrefix<T[K1], K2>
: never
: K extends keyof T
? T[K] extends string
? never
: Normalize<T[K]>
: never;
type KeyPrefix<N extends Namespace> = N extends keyof DefaultResources
? Fallback<string, keyof DefaultResources[N]> | undefined
? Normalize<DefaultResources[N]> | undefined
: string | undefined;

@@ -178,3 +195,3 @@

N extends Namespace = DefaultNamespace,
TKPrefix extends KeyPrefix<N> = undefined,
TKPrefix = undefined,
T = DefaultResources

@@ -184,17 +201,22 @@ > = N extends (keyof T)[] | Readonly<(keyof T)[]>

: N extends keyof T
? TKPrefix extends keyof T[N]
? Normalize<T[N][TKPrefix]>
: Normalize<T[N]>
? TKPrefix extends undefined
? Normalize<T[N]>
: NormalizeWithKeyPrefix<T[N], TKPrefix>
: string;
export type TFuncReturn<N, TKeys, TDefaultResult, T = DefaultResources> = N extends (keyof T)[]
export type TFuncReturn<
N,
TKeys,
TDefaultResult,
TKPrefix = undefined,
T = DefaultResources
> = N extends (keyof T)[]
? NormalizeMultiReturn<T, TKeys>
: N extends keyof T
? NormalizeReturn<T[N], TKeys>
? TKPrefix extends undefined
? NormalizeReturn<T[N], TKeys>
: NormalizeReturn<T[N], KeysWithSeparator<TKPrefix, TKeys>>
: Fallback<TDefaultResult>;
export interface TFunction<
N extends Namespace = DefaultNamespace,
TKPrefix extends KeyPrefix<N> = undefined
> {
export interface TFunction<N extends Namespace = DefaultNamespace, TKPrefix = undefined> {
<

@@ -207,3 +229,3 @@ TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,

options?: TOptions<TInterpolationMap> | string,
): TFuncReturn<N, TKeys, TDefaultResult>;
): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
<

@@ -217,9 +239,9 @@ TKeys extends TFuncKey<N, TKPrefix> | TemplateStringsArray extends infer A ? A : never,

options?: TOptions<TInterpolationMap> | string,
): TFuncReturn<N, TKeys, TDefaultResult>;
): TFuncReturn<N, TKeys, TDefaultResult, TKPrefix>;
}
type I18nKeyType<N extends Namespace> = TFuncKey<N> extends infer A ? A : never;
export interface TransProps<
K extends TFuncKey<N> extends infer A ? A : never,
K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
N extends Namespace = DefaultNamespace,
TKPrefix = undefined,
E extends Element = HTMLDivElement

@@ -237,17 +259,15 @@ > extends React.HTMLProps<E> {

values?: {};
t?: TFunction<N>;
t?: TFunction<N, TKPrefix>;
}
export function Trans<
K extends TFuncKey<N> extends infer A ? A : never,
K extends TFuncKey<N, TKPrefix> extends infer A ? A : never,
N extends Namespace = DefaultNamespace,
TKPrefix extends KeyPrefix<N> = undefined,
E extends Element = HTMLDivElement
>(props: TransProps<K, N, E>): React.ReactElement;
>(props: TransProps<K, N, TKPrefix, E>): React.ReactElement;
export function useSSR(initialI18nStore: Resource, initialLanguage: string): void;
export interface UseTranslationOptions<
N extends Namespace = DefaultNamespace,
TKPrefix extends KeyPrefix<N> = undefined
> {
export interface UseTranslationOptions<TKPrefix = undefined> {
i18n?: i18n;

@@ -258,3 +278,3 @@ useSuspense?: boolean;

type UseTranslationResponse<N extends Namespace, TKPrefix extends KeyPrefix<N>> = [
type UseTranslationResponse<N extends Namespace, TKPrefix> = [
TFunction<N, TKPrefix>,

@@ -274,3 +294,3 @@ i18n,

ns?: N | Readonly<N>,
options?: UseTranslationOptions<N, TKPrefix>,
options?: UseTranslationOptions<TKPrefix>,
): UseTranslationResponse<N, TKPrefix>;

@@ -277,0 +297,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc