-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,641 additions
and
3,034 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
export declare const initLocale: ( | ||
defaultLanguage: string, | ||
detectBrowserLanguage?: boolean, | ||
) => string; | ||
export declare const initLocale: (defaultLanguage: string, detectBrowserLanguage?: boolean) => string; |
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 |
---|---|---|
@@ -1,40 +1,28 @@ | ||
/// <reference types="react" /> | ||
export interface TProps { | ||
children: React.ReactNode; | ||
languages: Record<string, any>; | ||
defaultLanguage: string; | ||
detectBrowserLanguage?: boolean; | ||
children: React.ReactNode; | ||
languages: Record<string, any>; | ||
defaultLanguage: string; | ||
detectBrowserLanguage?: boolean; | ||
} | ||
export interface TContext { | ||
locale: string; | ||
setLocale: (language: string) => void; | ||
languages: Record<string, any>; | ||
defaultLanguage: string; | ||
locale: string; | ||
setLocale: (language: string) => void; | ||
languages: Record<string, any>; | ||
defaultLanguage: string; | ||
} | ||
export type TrContext = Omit<TContext, "setLocale">; | ||
type KeyPrefix<T extends string> = T extends "" ? "" : `.${T}`; | ||
type Suffix = "zero" | "one" | "two" | "few" | "many" | "female" | "male"; | ||
type DynamicSuffix = Partial<Record<Suffix, string>>; | ||
export type KeyPath<T> = ( | ||
T extends DynamicSuffix | ||
? "" | ||
: T extends object | ||
? { | ||
[K in Exclude<keyof T, symbol>]: `${K}${KeyPrefix<KeyPath<T[K]>>}`; | ||
}[Exclude<keyof T, symbol>] | ||
: "" | ||
) extends infer D | ||
? Extract<D, string> | ||
: never; | ||
export type KeyPath<T> = (T extends DynamicSuffix ? "" : T extends object ? { | ||
[K in Exclude<keyof T, symbol>]: `${K}${KeyPrefix<KeyPath<T[K]>>}`; | ||
}[Exclude<keyof T, symbol>] : "") extends infer D ? Extract<D, string> : never; | ||
export type TParams = { | ||
count?: number; | ||
[key: string]: any; | ||
count?: number; | ||
[key: string]: any; | ||
}; | ||
export type Autocomplete<schema> = KeyPath<schema>; | ||
export interface UseT extends TContext { | ||
T: <Key extends string, Params extends TParams>( | ||
key: Key, | ||
params?: Params, | ||
) => string; | ||
T: <Key extends string, Params extends TParams>(key: Key, params?: Params) => string; | ||
} | ||
export {}; |
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 |
---|---|---|
@@ -1,6 +1,2 @@ | ||
import { TParams, TrContext } from "./models"; | ||
export declare function tr<Key extends string, Params extends TParams>( | ||
{ locale, languages, defaultLanguage }: TrContext, | ||
key: Key, | ||
params?: Params, | ||
): string; | ||
export declare function tr<Key extends string, Params extends TParams>({ locale, languages, defaultLanguage }: TrContext, key: Key, params?: Params): string; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.