-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sankarsan Kampa <[email protected]>
- Loading branch information
1 parent
dd59a4b
commit e1b2c09
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
interface TranslateOption { | ||
/** The language name/ISO 639-1 code to translate from. If none is given, it will auto detect the source language. */ | ||
from?: string; | ||
/** The language name/ISO 639-1 code to translate to. If none is given, it will translate to English. */ | ||
to?: string; | ||
/** If `true`, it will return the raw output that was received from Google Translate. */ | ||
raw?: boolean; | ||
} | ||
|
||
interface TranslateResponse { | ||
/** The translated text */ | ||
text: string; | ||
from: { | ||
language: { | ||
/** Whether or not the API suggest a correction in the source language. */ | ||
didYouMean: boolean; | ||
/** The ISO 639-1 code of the language that the API has recognized in the text. */ | ||
iso: string; | ||
}; | ||
text: { | ||
/** Whether or not the API has auto corrected the original text. */ | ||
autoCorrected: boolean; | ||
/** The auto corrected text or the text with suggested corrections. Only returned if `from.text.autoCorrected` or `from.text.didYouMean` is `true`. */ | ||
value: string; | ||
/** Wherether or not the API has suggested corrections to the text. */ | ||
didYouMean: boolean; | ||
}; | ||
}; | ||
/** The raw response from Google Translate servers. Only returned if `options.raw` is `true` in the request options. */ | ||
raw: string; | ||
} | ||
|
||
|
||
/** | ||
* @param {String} text The text you want to translate. | ||
* @param {String} text The options for translating. | ||
*/ | ||
declare function translate(text: string, options?: TranslateOption): Promise<TranslateResponse>; | ||
|
||
export = translate; |