Limit for Translate API

104 views
Skip to first unread message

Wei Tat

unread,
Dec 3, 2015, 2:25:25 AM12/3/15
to Google Translate API Developer Forum
I know that currently there's a limit of 5k characters/request. Is there a way to bypass it?

Patrice (Google Cloud Support)

unread,
Dec 4, 2015, 3:12:40 PM12/4/15
to Google Translate API Developer Forum
Hi Wei,

There is currently no way to get around this, short of you parsing your input text and sending multiple requests.

Cheers!

Wei Tat

unread,
Dec 4, 2015, 11:40:07 PM12/4/15
to Google Translate API Developer Forum
Doing this for company plugin that has est 9k text with html tags each time.... why there's no flexibility

Patrice (Google Cloud Support)

unread,
Dec 7, 2015, 10:09:12 AM12/7/15
to Google Translate API Developer Forum
Hi Wei,

I don't have insights into the design decisions of the tool, so I can't help as to why this isn't as flexible as it could be.

I don't think it would be too hard to simply cut the 9k text into two easily to handle <5K batches and send the translation in two calls, no? This is the easy way to get around this limitation.

Cheers

Wei Tat

unread,
Dec 7, 2015, 11:50:48 AM12/7/15
to Google Translate API Developer Forum
Yes, it is easy to say but it is difficult to actually cut the text into parts when there is different types of html tags and the amount of characters received varies depending on the text field. sending the sentence to translate api is also important instead of broken parts so the structure of the sentence is there. and this process is suppose to be automated with the click of an button so we can't do the breaking of text into proper sentences manually. That will defeat the purpose to use this api.

jim.vale...@gmail.com

unread,
Dec 8, 2015, 7:25:27 AM12/8/15
to Google Translate API Developer Forum
We increased the limit to 15k and it still works.

Wei Tat

unread,
Dec 8, 2015, 7:42:07 AM12/8/15
to Google Translate API Developer Forum
Really??? Can you share your method? Currently I'm using ajax js

Jayshree

unread,
Dec 16, 2015, 1:32:20 AM12/16/15
to Google Translate API Developer Forum
Hi,

Really is it possible to increase the character limit for post call,
can you please share your method?

i am using following method:
and also suffering from the same problem of character limit during Post call as it 5 k only  and my web page contains minimum of 100000 characters on it.


    $(document).ready(function () {
        $(document).on("change", "#ddlTranslateLanguage", function () {
            debugger
            var htmlString = $(".template-container").html();
            $.ajax({
                type: "POST",
                url: "https://www.googleapis.com/language/translate/v2",
                headers: {
                    "X-HTTP-Method-Override": "GET"
                },
                data: { q: htmlString, target: "hi", source: "en", fields: "translations", key: "AIzaSyCnqpOsgFssI3wki_KJRmwlAXTWb_UtefA" },
                success: function (response) {
                    debugger
                    $(".template-container").html(response.data.translations[0]["translatedText"])
                    Notifications.DisplayHelper("success", 'success');
                },
                error: function (error) {
                    debugger
                    Notifications.DisplayHelper("error", 'error');
                }
            });

        });
    });

Wei Tat

unread,
Dec 16, 2015, 6:08:16 AM12/16/15
to Google Translate API Developer Forum
Hi, I actually manage to did it. I used array and regex to detect opening and closing tags then send each array to translate.

Jayshree

unread,
Dec 16, 2015, 6:16:12 AM12/16/15
to Google Translate API Developer Forum
Hi,

Thanks Wie..

After translating each request, in think you were also need to put it at the same location where it was.

It is fine for small pages.

But, Is it not too much lengthy where  100000 character in one page.

Wei Tat

unread,
Dec 16, 2015, 7:51:17 PM12/16/15
to Google Translate API Developer Forum
What I did was storing the string with the html element. As you know, HTML elements won't be translated by Translate API so the returned text is store in a variable and then repeat and add on with append or += . 

When the loop run finish, then I will display the string(inclusive of HTML tags) in the text area. However do note that you must set async to false otherwise the translated content would be messed up. 100000 characters per page may result in a near 10 seconds lag because of async and incoming strings. 

Another way is to detect 5000 chars and store but I could not figure that out because if the string has HTML tags, it would be quite hard.
Reply all
Reply to author
Forward
0 new messages