I’m using v2. I need to translate text like the below, which have important whitespace (leading/trailing, new lines \n, tabs \t). The API seems to respect the leading whitespace and \n, but drops trailing whitespace and \t. Furthermore, I have to specify the undocumented format_ parameter to avoid symbols like ’ being output as HTML entities. Is it possible to use the translate API and respect whitespace?
translate_client.translate(" it's a sentence.\n\tAnd here is a new one ", 'fr', format_='text')
Result:
{'translatedText': " c'est une phrase.\nEt en voici un nouveau",
'detectedSourceLanguage': 'en',
'input': " it's a sentence.\n\tAnd here is a new one "}