Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: update i18n types definition

johnnyjoy0a5111e4b0fa
diff --git a/web/src/types/utils/nestedKeyOf.types.ts b/web/src/types/utils/nestedKeyOf.types.ts
deleted file mode 100644
index 472f7f4d3..000000000
--- a/web/src/types/utils/nestedKeyOf.types.ts
+++ /dev/null
@@ -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;
diff --git a/web/src/utils/i18n.ts b/web/src/utils/i18n.ts
index ca9434393..9e6bf97a3 100644
--- a/web/src/utils/i18n.ts
+++ b/web/src/utils/i18n.ts
@@ -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>;