About API V2
If you use the API V2 version of the SDK, there will be a problem that the number of characters in the content exceeds 5K (1024*5) and cannot be translated, and an error will be reported: Your client has issued a malformed or illegal request. <ins>That’s all we know.</ins>
, that is to say, if you use the V2 version of the SDK, you cannot translate long The text corresponds to the base
version in the official document.
API V3
Although the length of the API V3 version is limited, the maximum can be submitted to 30KB, which is sufficient for most scenarios, but there are two problems here.
The first case is that when translating code fragments, if you manually replace the code fragments that need to be translated into <span class="notranslate">--key--</span>
, and then mark the response locally key
and the corresponding code The segment cache becomes map
, and then the data passed back after translation is manually replaced, which will lead to a situation: although the parts that do not need translation are marked notranslate
, although this part of the tag is not translated and will remain, but in some cases, the <span>
part of the tag is not translated and the key
part defined in the tag will be inserted as a plain text for translation After a certain part of the program, and then need to manually according to the specific situation, and this situation may sometimes be unpredictable.
Another situation is that in fact, the VPI V3 interface itself will not be able to translate part of the content of <code>
, but it will cause the line break in the original <code>
to be lost, and the final translation content is A bunch of unformatted content that looks cluttered. If you don't use the first tag form and throw it directly to Google Translate, you need to replace the line break in the content to be translated, that is \n
with <br>
before submitting the translation <br>
, of course this \n
\r\n
windows.
The above summary of the two versions of the Google Translate SDK and the three situations, basically, anyone who needs to use Google Translate will encounter it, but when looking for information, there is actually not much relevant information, which is more troublesome and troublesome to process. . I leave this article as a summary, and I hope that the latecomers can provide a certain reference when they encounter the relevant situation and cannot start.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。