Commit 0a5111e4 authored by johnnyjoy's avatar johnnyjoy

chore: update i18n types definition

parent 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;
......@@ -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>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment