feat/landing #30
2
package-lock.json
generated
2
package-lock.json
generated
@ -21,6 +21,7 @@
|
||||
"i18next": "^23.16.4",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^15.1.1",
|
||||
"react-icons": "^5.3.0",
|
||||
"react-router-dom": "^6.27.0"
|
||||
},
|
||||
@ -8964,6 +8965,7 @@
|
||||
"version": "15.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-15.1.1.tgz",
|
||||
"integrity": "sha512-R/Vg9wIli2P3FfeI8o1eNJUJue5LWpFsQePCHdQDmX0Co3zkr6kdT8gAseb/yGeWbNz1Txc4bKDQuZYsC0kQfw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.25.0",
|
||||
"html-parse-stringify": "^3.0.1"
|
||||
|
@ -29,6 +29,7 @@
|
||||
"i18next": "^23.16.4",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-i18next": "^15.1.1",
|
||||
"react-icons": "^5.3.0",
|
||||
"react-router-dom": "^6.27.0"
|
||||
},
|
||||
|
31
src/models/i18next.d.ts
vendored
Normal file
31
src/models/i18next.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
import defaultLocale from '../../locales/ru.json';
|
||||
|
||||
type Split<S extends string, D extends string> =
|
||||
S extends `${infer A}${D}${infer B}` ? [A, ...Split<B, D>] : [S];
|
||||
|
||||
type NestedObject<T extends string[]> =
|
||||
T extends [infer Head, ...infer Tail] ?
|
||||
Head extends string ?
|
||||
{ [key in Head]: NestedObject<Tail extends string[] ? Tail : []> } : never :
|
||||
string;
|
||||
|
||||
// Основная утилита для обработки union type
|
||||
type CreateTree<T> =
|
||||
UnionToIntersection<T extends infer U ?
|
||||
U extends string ?
|
||||
NestedObject<Split<U, '.'>> : never : never>;
|
||||
|
||||
// Утилита для объединения типов
|
||||
type UnionToIntersection<U> =
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
||||
|
||||
type LanguageResource = CreateTree<keyof typeof defaultLocale>;
|
||||
|
||||
declare module "i18next" {
|
||||
interface CustomTypeOptions {
|
||||
resources: {
|
||||
'~': LanguageResource
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user