Parcourir la source

Add types for translate-google

ghorsington il y a 5 ans
Parent
commit
b2eec43339
2 fichiers modifiés avec 26 ajouts et 1 suppressions
  1. 5 1
      bot/src/commands/news_aggregator.ts
  2. 21 0
      bot/src/typedefs/translate-google.d.ts

+ 5 - 1
bot/src/commands/news_aggregator.ts

@@ -1,9 +1,10 @@
 import TurndownService, { Options } from "turndown";
 import interval from "interval-promise";
-import { client } from "../client";
+import { client, forumClient } from "../client";
 import sha1 from "sha1";
 import * as path from "path";
 import * as fs from "fs";
+import translate from "translate-google";
 
 import { IAggregator, NewsPostItem, INewsPostData } from "./aggregators/aggregator";
 import { ICommand } from "./command";
@@ -19,6 +20,9 @@ const aggregators : IAggregator[] = [];
 let aggregateChannelID : string = null;
 const AGGREGATOR_MANAGER_CHANNEL = "aggregatorManager";
 
+const FORUMS_STAGING_ID = 54;
+const FORUMS_NEWS_ID = 49;
+
 // TODO: Run BBCode converter instead
 const turndown = new TurndownService();
 turndown.addRule("image", {

+ 21 - 0
bot/src/typedefs/translate-google.d.ts

@@ -0,0 +1,21 @@
+declare module "translate-google" {
+
+    export interface TranslationOptions {
+        from?: string;
+        to?: string;
+    }
+
+    export interface LanguageService {
+        isSupported(desiredLang: string) : boolean;
+        getCode(language: string) : string;
+    }
+
+    export type LanguageData = { [langCode: string] : string } & LanguageService;
+
+    export type TranslationInput = object | string | string[];
+
+    export type TranslateFunction = <T extends TranslationInput>(input: T, opts?: TranslationOptions, domain?: string) => Promise<T>;
+    
+    export const translateFunction : TranslateFunction & { languages: LanguageData };
+    export default translateFunction;
+}