Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
context less version of Trans component (#1588)
* context less version of Trans component * some adjustements
- Loading branch information
Showing
16 changed files
with
842 additions
and
523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { i18n, TFuncKey, Namespace, TypeOptions, TFunction, KeyPrefix } from 'i18next'; | ||
import * as React from 'react'; | ||
|
||
type DefaultNamespace = TypeOptions['defaultNS']; | ||
|
||
type TransChild = React.ReactNode | Record<string, unknown>; | ||
export type TransProps< | ||
K extends TFuncKey<N, TKPrefix> extends infer A ? A : never, | ||
N extends Namespace = DefaultNamespace, | ||
TKPrefix = undefined, | ||
E = React.HTMLProps<HTMLDivElement> | ||
> = E & { | ||
children?: TransChild | TransChild[]; | ||
components?: readonly React.ReactElement[] | { readonly [tagName: string]: React.ReactElement }; | ||
count?: number; | ||
context?: string; | ||
defaults?: string; | ||
i18n?: i18n; | ||
i18nKey?: K | K[]; | ||
ns?: N; | ||
parent?: string | React.ComponentType<any> | null; // used in React.createElement if not null | ||
tOptions?: {}; | ||
values?: {}; | ||
shouldUnescape?: boolean; | ||
t?: TFunction<N, TKPrefix>; | ||
}; | ||
|
||
export function Trans< | ||
K extends TFuncKey<N, TKPrefix> extends infer A ? A : never, | ||
N extends Namespace = DefaultNamespace, | ||
TKPrefix extends KeyPrefix<N> = undefined, | ||
E = React.HTMLProps<HTMLDivElement> | ||
>(props: TransProps<K, N, TKPrefix, E>): React.ReactElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { ThirdPartyModule } from 'i18next'; | ||
|
||
export const initReactI18next: ThirdPartyModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.