1
0
Fork 0

Changed stuff, added filter for statistics module

This commit is contained in:
Techognito 2025-09-02 16:37:06 +02:00
parent 4a91ae2bf9
commit fe87374e47
251 changed files with 3295 additions and 1705 deletions

View file

@ -1,3 +1,20 @@
### 15.7.3
- exports TransSelectorProps [1862](https://github.com/i18next/react-i18next/pull/1862) to address [1861](https://github.com/i18next/react-i18next/issues/1861)
### 15.7.2
- update i18next dependency
### 15.7.1
- Fix: \_EnableSelector type (for compatibility, enableSelector does not exist in TypeOptions) [1858](https://github.com/i18next/react-i18next/pull/1858)
### 15.7.0
- add new selector API to improve TypeScript IDE performance [1852](https://github.com/i18next/react-i18next/pull/1852)
- read more about it [here](https://github.com/i18next/i18next/blob/master/CHANGELOG.md#2540)
### 15.6.1
avoid exception when passing bindI18n: false [1856](https://github.com/i18next/react-i18next/pull/1856)

View file

@ -1,9 +1,23 @@
import type { i18n, ParseKeys, Namespace, TypeOptions, TOptions, TFunction } from 'i18next';
import type {
i18n,
ApplyTarget,
ConstrainTarget,
GetSource,
ParseKeys,
Namespace,
SelectorFn,
TypeOptions,
TOptions,
TFunction,
} from 'i18next';
import * as React from 'react';
type _DefaultNamespace = TypeOptions['defaultNS'];
type _EnableSelector = TypeOptions['enableSelector'];
type TransChild = React.ReactNode | Record<string, unknown>;
type $NoInfer<T> = [T][T extends T ? 0 : never];
export type TransProps<
Key extends ParseKeys<Ns, TOpt, KPrefix>,
Ns extends Namespace = _DefaultNamespace,
@ -27,14 +41,56 @@ export type TransProps<
t?: TFunction<Ns, KPrefix>;
};
export function Trans<
Key extends ParseKeys<Ns, TOpt, KPrefix>,
export interface TransLegacy {
<
Key extends ParseKeys<Ns, TOpt, KPrefix>,
Ns extends Namespace = _DefaultNamespace,
KPrefix = undefined,
TContext extends string | undefined = undefined,
TOpt extends TOptions & { context?: TContext } = { context: TContext },
E = React.HTMLProps<HTMLDivElement>,
>(
props: TransProps<Key, Ns, KPrefix, TContext, TOpt, E>,
): React.ReactElement;
}
export interface TransSelectorProps<
Key,
Ns extends Namespace = _DefaultNamespace,
KPrefix = undefined,
TContext extends string | undefined = undefined,
TOpt extends TOptions & { context?: TContext } = { context: TContext },
E = React.HTMLProps<HTMLDivElement>,
>(props: TransProps<Key, Ns, KPrefix, TContext, TOpt, E>): React.ReactElement;
> {
children?: TransChild | readonly TransChild[];
components?: readonly React.ReactElement[] | { readonly [tagName: string]: React.ReactElement };
count?: number;
context?: TContext;
defaults?: string;
i18n?: i18n;
i18nKey?: Key;
ns?: Ns;
parent?: string | React.ComponentType<any> | null; // used in React.createElement if not null
tOptions?: TOpt;
values?: {};
shouldUnescape?: boolean;
t?: TFunction<Ns, KPrefix>;
}
export interface TransSelector {
<
Target extends ConstrainTarget<TOpt>,
Key extends SelectorFn<GetSource<$NoInfer<Ns>, KPrefix>, ApplyTarget<Target, TOpt>, TOpt>,
const Ns extends Namespace = _DefaultNamespace,
KPrefix = undefined,
TContext extends string | undefined = undefined,
TOpt extends TOptions & { context?: TContext } = { context: TContext },
E = React.HTMLProps<HTMLDivElement>,
>(
props: TransSelectorProps<Key, Ns, KPrefix, TContext, TOpt> & E,
): React.ReactElement;
}
export const Trans: _EnableSelector extends true | 'optimize' ? TransSelector : TransLegacy;
export type ErrorCode =
| 'NO_I18NEXT_INSTANCE'

View file

@ -1 +1 @@
{"type":"module","version":"15.6.1"}
{"type":"module","version":"15.7.3"}

View file

@ -10,11 +10,17 @@ import type {
KeyPrefix,
} from 'i18next';
import * as React from 'react';
import { Trans, TransProps, ErrorCode, ErrorArgs } from './TransWithoutContext.js';
import {
Trans,
TransProps,
TransSelectorProps,
ErrorCode,
ErrorArgs,
} from './TransWithoutContext.js';
export { initReactI18next } from './initReactI18next.js';
export const TransWithoutContext: typeof Trans;
export { Trans, TransProps, ErrorArgs, ErrorCode };
export { Trans, TransProps, TransSelectorProps, ErrorArgs, ErrorCode };
export function setDefaults(options: ReactOptions): void;
export function getDefaults(): ReactOptions;
@ -67,7 +73,10 @@ type _DefaultNamespace = TypeOptions['defaultNS'];
export function useSSR(initialI18nStore: Resource, initialLanguage: string): void;
export interface UseTranslationOptions<KPrefix> {
// If the version is earlier than i18next v25.4.0, enableSelector does not exist in TypeOptions, so a conditional type is used to maintain type compatibility.
type _EnableSelector = TypeOptions extends { enableSelector: infer U } ? U : false;
export type UseTranslationOptions<KPrefix> = {
i18n?: i18n;
useSuspense?: boolean;
keyPrefix?: KPrefix;
@ -75,7 +84,7 @@ export interface UseTranslationOptions<KPrefix> {
nsMode?: 'fallback' | 'default';
lng?: string;
// other of these options might also work: https://github.com/i18next/i18next/blob/master/index.d.ts#L127
}
};
export type UseTranslationResponse<Ns extends Namespace, KPrefix> = [
t: TFunction<Ns, KPrefix>,
@ -96,13 +105,29 @@ export type FallbackNs<Ns> = Ns extends undefined
? Ns
: _DefaultNamespace;
export function useTranslation<
const Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined = undefined,
const KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
>(
ns?: Ns,
options?: UseTranslationOptions<KPrefix>,
): UseTranslationResponse<FallbackNs<Ns>, KPrefix>;
export const useTranslation: _EnableSelector extends true | 'optimize'
? UseTranslationSelector
: UseTranslationLegacy;
interface UseTranslationLegacy {
<
const Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined = undefined,
const KPrefix extends KeyPrefix<FallbackNs<Ns>> = undefined,
>(
ns?: Ns,
options?: UseTranslationOptions<KPrefix>,
): UseTranslationResponse<FallbackNs<Ns>, KPrefix>;
}
interface UseTranslationSelector {
<
const Ns extends FlatNamespace | $Tuple<FlatNamespace> | undefined = undefined,
const KPrefix = undefined,
>(
ns?: Ns,
options?: UseTranslationOptions<KPrefix>,
): UseTranslationResponse<FallbackNs<Ns>, KPrefix>;
}
// Need to see usage to improve this
export function withSSR(): <Props>(WrappedComponent: React.ComponentType<Props>) => {

View file

@ -1,6 +1,6 @@
{
"name": "react-i18next",
"version": "15.6.1",
"version": "15.7.3",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"types": "./index.d.mts",
@ -68,7 +68,7 @@
"html-parse-stringify": "^3.0.1"
},
"peerDependencies": {
"i18next": ">= 23.2.3",
"i18next": ">= 25.4.1",
"react": ">= 16.8.0",
"typescript": "^5"
},
@ -123,7 +123,7 @@
"eslint-plugin-testing-library": "^6.5.0",
"happy-dom": "^14.12.3",
"husky": "^9.1.7",
"i18next": "^25.3.0",
"i18next": "^25.4.1",
"lint-staged": "^15.5.2",
"mkdirp": "^3.0.1",
"prettier": "^3.6.2",