eko / GoogleTranslateBundle

A Symfony bundle to deals with Google Translate API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Translate texts longer than 2000 bytes

liviucmg opened this issue · comments

Hi there,

The Google API allows for a maximum of 2K characters per query, if you're using GET. See here:
https://cloud.google.com/translate/v2/using_rest#detect-WorkingResults

If you want to translate longer texts, one solution is to split it up into multiple queries. The split should be done at key characters, such as newlines (end of paragraphs), dots (end of sentences) or at worst at spaces (end of a word). I am going to submit a pull request for an implementation soon.

Another solution would be to use POST instead of GET, which apparently raises this limit to 5K characters.

Cheers!