Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
0a5111e4
Commit
0a5111e4
authored
Dec 07, 2024
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update i18n types definition
parent
67f8811f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
nestedKeyOf.types.ts
web/src/types/utils/nestedKeyOf.types.ts
+0
-3
i18n.ts
web/src/utils/i18n.ts
+4
-1
No files found.
web/src/types/utils/nestedKeyOf.types.ts
deleted
100644 → 0
View file @
67f8811f
export
type
NestedKeyOf
<
T
,
K
=
keyof
T
>
=
K
extends
keyof
T
&
(
string
|
number
)
?
`
${
K
}
`
|
(
T
[
K
]
extends
object
?
`
${
K
}
.
${
NestedKeyOf
<
T
[
K
]
>
}
`
:
never
)
:
never
;
web/src/utils/i18n.ts
View file @
0a5111e4
...
...
@@ -2,7 +2,6 @@ import { FallbackLngObjList } from "i18next";
import
{
useTranslation
}
from
"react-i18next"
;
import
i18n
,
{
locales
,
TLocale
}
from
"@/i18n"
;
import
enTranslation
from
"@/locales/en.json"
;
import
type
{
NestedKeyOf
}
from
"@/types/utils/nestedKeyOf.types"
;
export
const
findNearestMatchedLanguage
=
(
language
:
string
):
Locale
=>
{
if
(
locales
.
includes
(
language
as
TLocale
))
{
...
...
@@ -33,6 +32,10 @@ export const findNearestMatchedLanguage = (language: string): Locale => {
return
(
i18n
.
store
.
options
.
fallbackLng
as
FallbackLngObjList
).
default
[
0
]
as
Locale
;
};
type
NestedKeyOf
<
T
,
K
=
keyof
T
>
=
K
extends
keyof
T
&
(
string
|
number
)
?
`
${
K
}
`
|
(
T
[
K
]
extends
object
?
`
${
K
}
.
${
NestedKeyOf
<
T
[
K
]
>
}
`
:
never
)
:
never
;
// Represents the keys of nested translation objects.
export
type
Translations
=
NestedKeyOf
<
typeof
enTranslation
>
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment