diff --git a/extensions/src/textClassification/services/translation.ts b/extensions/src/textClassification/services/translation.ts index ee3718aa4..94a59d2e5 100644 --- a/extensions/src/textClassification/services/translation.ts +++ b/extensions/src/textClassification/services/translation.ts @@ -19,9 +19,9 @@ export const getTranslationURL = (params: SearchParams) => { export const getTranslationToEnglish = async (words: string) => { if (cachedTranslations.has(words)) return cachedTranslations.get(words); - const endpoint = getTranslationURL({ language: "en", text: encodeURIComponent(words) }); + const endpoint = getTranslationURL({ language: "en", text: words }); // words already encoded try { - const json: { result: string } = await (await fetchWithTimeout(endpoint, { timeoutMs: 30 })).json(); + const json: { result: string } = await (await fetchWithTimeout(endpoint, { timeoutMs: 30000 })).json(); // 30ms was too short const translated = json.result; cachedTranslations.set(words, translated); return translated; @@ -30,4 +30,4 @@ export const getTranslationToEnglish = async (words: string) => { console.warn(`error fetching translate result! ${error}`); return ''; } -} \ No newline at end of file +}