mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
feat: add i18n with type safety
This commit is contained in:
9
inertia/types/i18n.d.ts
vendored
Normal file
9
inertia/types/i18n.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import 'i18next';
|
||||
import { resources } from '../i18n';
|
||||
|
||||
declare module 'i18next' {
|
||||
interface CustomTypeOptions {
|
||||
returnNull: false;
|
||||
resources: (typeof resources)['fr'];
|
||||
}
|
||||
}
|
||||
24
inertia/types/utils.d.ts
vendored
Normal file
24
inertia/types/utils.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
type Join<K, P> = K extends string
|
||||
? P extends string
|
||||
? `${K}${'' extends P ? '' : '.'}${P}`
|
||||
: never
|
||||
: never;
|
||||
|
||||
type Paths<T> = T extends object
|
||||
? {
|
||||
[K in keyof T]-?: K extends string
|
||||
? `${K}` | Join<K, Paths<T[K]>>
|
||||
: never;
|
||||
}[keyof T]
|
||||
: '';
|
||||
|
||||
type Leaves<T> = T extends object
|
||||
? {
|
||||
[K in keyof T]-?: Join<K, Leaves<T[K]>>;
|
||||
}[keyof T]
|
||||
: '';
|
||||
|
||||
type RemoveSuffix<
|
||||
Key extends string,
|
||||
SuffixAfter extends string = '_',
|
||||
> = Key extends `${infer Prefix}${SuffixAfter}${string}` ? Prefix : Key;
|
||||
Reference in New Issue
Block a user