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

@ -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>) => {