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 "}
```
Hi @kellymarchisio,
Welcome and thank you for reaching out to our community.
I understand that you wanted to keep the newline and tab tags in your sentences during and after the translation process. There are a couple of possible options for you; kindly look into the preserve_formatting parameter or the translate_document method.
Here are some resources for your reference.
Hope this helps.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |