diff --git a/index.d.ts b/index.d.ts index b62f103..6852cc1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -39,6 +39,14 @@ export interface TranslationResult { */ score?: number; }; + /** + * The transliteration of input text + */ + inputTransliteration?: string; + /** + * The transliteration of output text + */ + outputTransliteration?: { text?: string, script?: string }; /** * The original response from Bing translator */ diff --git a/src/index.js b/src/index.js index 805afef..d80ca25 100644 --- a/src/index.js +++ b/src/index.js @@ -142,7 +142,7 @@ function makeRequestURL(isSpellCheck, useEPT) { // PENDING: might no rate limit but some languages are not supported for now // (See also the `eptLangs` field in src/config.json) : '&ref=TThis' + - '&edgepdftranslator=1' + '&edgepdftranslator=1' ) } @@ -315,6 +315,8 @@ async function translate(text, from, to, correct, raw, userAgent, proxyAgents) { const translation = body[0].translations[0] const detectedLang = body[0].detectedLanguage || {} + const inputTransliteration = body[1]?.inputTransliteration || undefined; + const outputTransliteration = body[0].translations[0]?.transliteration || {}; /** * @type {TranslationResult} @@ -327,7 +329,9 @@ async function translate(text, from, to, correct, raw, userAgent, proxyAgents) { from: detectedLang.language, to: translation.to, score: detectedLang.score - } + }, + inputTransliteration, + outputTransliteration } if (correct) {