]> Untitled Git - lemmy-ui.git/blobdiff - generate_translations.js
address review comments
[lemmy-ui.git] / generate_translations.js
index 313e80031e8c08d5c83332310fb4dfca6152feb7..594f574c3433778551159c28cc8ae5d32369ee6c 100644 (file)
@@ -32,17 +32,17 @@ const baseLanguage = "en";
 fs.readFile(`${translationDir}${baseLanguage}.json`, "utf8", (_, fileStr) => {
   const keys = Object.keys(JSON.parse(fileStr));
 
-  const data = `import * as i18n from "i18next";
-
-type I18nKeys = 
-${keys.map(key => `  | "${key}"`).join("\n")};
+  const data = `import { i18n } from "i18next";
 
 declare module "i18next" {
-  export interface TFunction {
+  export type I18nKeys = 
+${keys.map(key => `    | "${key}"`).join("\n")};
+  
+  export interface TFunctionTyped {
     // basic usage
     <
       TResult extends TFunctionResult = string,
-      TInterpolationMap extends object = StringMap
+      TInterpolationMap extends Record<string, unknown> = StringMap
     >(
       key: I18nKeys | I18nKeys[],
       options?: TOptions<TInterpolationMap> | string
@@ -50,13 +50,17 @@ declare module "i18next" {
     // overloaded usage
     <
       TResult extends TFunctionResult = string,
-      TInterpolationMap extends object = StringMap
+      TInterpolationMap extends Record<string, unknown> = StringMap
     >(
       key: I18nKeys | I18nKeys[],
       defaultValue?: string,
       options?: TOptions<TInterpolationMap> | string
     ): TResult;
   }
+
+  export interface i18nTyped extends i18n {
+    t: TFunctionTyped;
+  }
 }
 `;