mirror of
https://github.com/usememos/memos.git
synced 2025-11-08 08:21:49 +08:00
chore: update i18n types definition
This commit is contained in:
parent
67f8811f3f
commit
0a5111e4b0
2 changed files with 4 additions and 4 deletions
|
|
@ -1,3 +0,0 @@
|
|||
export type NestedKeyOf<T, K = keyof T> = K extends keyof T & (string | number)
|
||||
? `${K}` | (T[K] extends object ? `${K}.${NestedKeyOf<T[K]>}` : never)
|
||||
: never;
|
||||
|
|
@ -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>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue