nodejs-translate icon indicating copy to clipboard operation
nodejs-translate copied to clipboard

Translation not respecting the targeted language, resulting in mixed language translation

Open cchen028 opened this issue 3 years ago • 0 comments

Hi all,

I am encountering an issue recently regarding to translation which has been working fine for the past few months. When I provide an input text (Chinese) , and attempt to translate to one of the languages (Japanese, Korean, French, there could be more but these are the only languages I tested with) , it only translates the first couple lines and the rest is replaced with English translation.

Below is my code for getting the translation:

const translateAPI = new Translate({ projectId: process.env.PROJECT_ID, keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS });
const [tempTrans] = await translateAPI.translate(text, to);
return he.decode(tempTrans);

Please see attached debugged screenshot for the issue.

Below shows the input text is in Chinese: image

Below shows targeted language is Japanese: image

Below shows the translated language is a mixed of Japanese and English: image

I have attached the raw input text file. (Input is in Chinese)

When the input text is English, the translation translates as expected, but when the input is in Chinese this issue happens. Any help or advise is appreciated, thanks in advance. 2022-07-03T00_43_18_742Z-translation-debug-input.txt

Environment details

  • OS: Windows
  • Node.js version: Node 10 and 14
  • npm version: 6.14.17
  • @google-cloud/translate version: 6.3.1

cchen028 avatar Jul 04 '22 18:07 cchen028