Use Google Translation API to translate In-Portal language packs

37 views
Skip to first unread message

Dmitry A.

unread,
Apr 22, 2010, 5:44:19 PM4/22/10
to In-Portal Localization Team
Hello guys,


I have came across the idea that we can start with using Google API to
translate current Language packs and even integrate Google JS
translator into out Phrases part of where ever it make sense to use
the best.

http://code.google.com/apis/ajaxlanguage/documentation


Everyone on the list please share your opinion on this.


Thanks.

DA

--
You received this message because you are subscribed to the Google Groups "In-Portal Localization Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-loc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-local?hl=en.

Alexander Obuhovich

unread,
Apr 23, 2010, 2:48:28 AM4/23/10
to in-port...@googlegroups.com
Here is link to php class, that will do that:

http://www.daniweb.com/code/post969520.html
--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com

Phil -- wbtc.fr --

unread,
Apr 23, 2010, 4:53:04 AM4/23/10
to in-port...@googlegroups.com
Hi,

as per my experience in using google translation everyday in many different languages, it works well for single word and short sentences, and works very badly for complete sentence.
This is not really a problem in our case, as long sentences always need a custom translation according to customer marketing needs, while single words no need special adjustments, then it could be nice to have it, if we can override translation for given labels.

Phil.


2010/4/22 Dmitry A. <dand...@gmail.com>

Alexander Obuhovich

unread,
Apr 23, 2010, 9:30:16 AM4/23/10
to in-port...@googlegroups.com
I propose we add virtual field named "Translate Using Google" checkbox, that will translate all labels from primary language to given language once it is saved. Visible only when language is created.

Dmitry Andrejev

unread,
Apr 23, 2010, 11:08:53 AM4/23/10
to in-port...@googlegroups.com
Yes, I am all for it!

Can we do this ASAP in 5.1.x so we can provide Language packs for everyone.

We still need some sort of tools on In-Portal.com site for proper Language pack management.


DA.

Alexander Obuhovich

unread,
Apr 23, 2010, 4:26:16 PM4/23/10
to in-port...@googlegroups.com
That tools won't be available soon based on human resources available.

Phil -- wbtc.fr --

unread,
Apr 24, 2010, 5:45:48 AM4/24/10
to in-port...@googlegroups.com
it's a cool feature, but we don't modify it everyday, and it works not so bad actually ;-)

if you need to translate a whole pack, it's easy to do using google translation online, it takes few minutes... and may take hours implementing it... would you like me to do a "google-translated" lang packs?

2010/4/23 Alexander Obuhovich <aik....@gmail.com>

Alexander Obuhovich

unread,
Apr 25, 2010, 9:36:54 AM4/25/10
to in-port...@googlegroups.com
I heard, that Dmitry was already implementing my idea. I hope patch will be available soon.

Phil -- wbtc.fr --

unread,
Apr 25, 2010, 12:39:01 PM4/25/10
to in-port...@googlegroups.com
cool ^-^

2010/4/25 Alexander Obuhovich <aik....@gmail.com>

Alexander Obuhovich

unread,
May 23, 2010, 12:04:43 PM5/23/10
to in-port...@googlegroups.com
Ping on this. Still no patch?

Dmitry Andrejev

unread,
May 23, 2010, 6:37:22 PM5/23/10
to in-port...@googlegroups.com
Sorry for a delay with this.

I'll be working on 5.1.0 branch to provide a patch for this shortly.

DA.

Alexander Obuhovich

unread,
Jun 5, 2010, 1:47:26 PM6/5/10
to in-port...@googlegroups.com
So, where is the patch again? You say sorry for the delay and delay again.

Alexander Obuhovich

unread,
Jun 10, 2010, 3:13:37 PM6/10/10
to in-port...@googlegroups.com
I really need that script, since I need to create Russian language pack. Can write it myself, but since you've already started it, then please share.

Alexander Obuhovich

unread,
Sep 1, 2010, 4:01:06 AM9/1/10
to in-port...@googlegroups.com
So no patch, no task, no nothing. That's really bad, since Dmitry told me few months ago, that he really got a working patch already. It's really taking that long to attach it here and create appropriate task?

Alexander Obuhovich

unread,
Sep 7, 2010, 1:22:56 PM9/7/10
to in-port...@googlegroups.com
I'm not hoping for any response here, but patch will be appreciated.

Dmitry A.

unread,
Jan 6, 2011, 11:57:37 PM1/6/11
to in-port...@googlegroups.com
Hi everyone and Alex ;)


Sorry for a long delay here, other things kept me busy. Finally, I have found some time to code promised integration with Google Translate API.

Good thing that I have learned is that Google released a new new version of their API (even though it's in labs yet). Here is link if someone want's to check it out http://code.google.com/apis/language/translate/v2/getting_started.html .


What I am trying to figure out is how to make this whole thing even more useful. To make things easier let's recap what need's to be done:

1. Ability to translate the while Language Pack at the time of creation and copying from another language.

2. Ability to translate right from the Add/Edit Phrase interface in Admin? I suppose we need to have here Source and Target languages somewhere - not sure where for now.


Please let me know if you have more ideas here. Let's finalize this and I'll get it quick I promise this time!


Cheers!

Alexander Obuhovich

unread,
Jan 7, 2011, 4:00:49 AM1/7/11
to in-port...@googlegroups.com
Why we need to integrate google translate into phrase add/edit form if there are already a website that does translation.

If you need to translate, then I see no problems in going to website that does that for us.

Another thing is when you need to mass-translate. This is where this could be useful.


--
You received this message because you are subscribed to the Google Groups "In-Portal Localization Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-loc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-local?hl=en.

Phil -- wbtc.fr --

unread,
Jan 7, 2011, 10:49:17 AM1/7/11
to in-port...@googlegroups.com
1. usefull

2. same opinion as Alex, it'd take time for little result, as when we edit a phrase, we want to manually change the translation, and not translate it automatically once again ;)

2011/1/7 Alexander Obuhovich <aik....@gmail.com>

Dmitry A.

unread,
Jan 31, 2011, 1:00:25 AM1/31/11
to in-port...@googlegroups.com
Hi guys,


Here is a working prototype (as a patch).

Will be doing some improvements to speed up the translation process.


DA
GoogleTranslatePrototype.patch

Alexander Obuhovich

unread,
Jan 31, 2011, 2:12:02 AM1/31/11
to in-port...@googlegroups.com
Thanks for long waited patch. Here are few notes from me:
  • What is: AIzaSyDzfNLxl91mDRW1OPIKJfN-oETIHuzvMEY key. Is it domain-based (or how user can change it) and maybe we can do it all without it?
  • Why you set USER_AGENT for curl request with strange "FeedBurner feed" comment near it? maybe it will work without it too?
  • How long does script execute (I mean that curl request), assuming you have 3000 phrases in language pack?

Maybe it's better to move $this->Application->getUnitOption('phrases', 'TableName') code before update cycle starts.


--
You received this message because you are subscribed to the Google Groups "In-Portal Localization Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-loc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-local?hl=en.

Dmitry A.

unread,
Jan 31, 2011, 10:29:48 AM1/31/11
to in-port...@googlegroups.com
Hi Alex,


Thanks for your code review. The answer is yes - there is a room for optimization which I was going to do in any case.

Answers:

1. Yes, it's a API key that needs to be present in order for Translation API to work. Currently I have hard-coded mine since need to figure out the difference between API Key used for Google Maps (configuration belongs to In-Link module) and the one I need here. I believe these are 2 different keys, but I'll check and merge it if needed.

2. Yes, comment will go away the same as the whole Agent part. Still need to run few more tests.

3. Translation Speed - yes it worked for me, but took quite a bit which is not acceptable for Production version. I am planning on changing the code to make fewer Curl requests by translating 10 or 20 labels at a time. By the way, how much data would be 5K? I have read that POST method for translation will support up to 5K, but haven't clearly converted it to any legitimate number to understand how much I can fit in a single request. 

4. Yes, table will be moved out of the loop.


Cheers!


DA

Alexander Obuhovich

unread,
Jan 31, 2011, 1:01:55 PM1/31/11
to in-port...@googlegroups.com
Ok, try to use "batch" functionality (google has it in data api, but I don't know about translation api).

You can collect phrases to be translated into a string and when it's length will be just before 5KB you can send them all together.




DA

--
You received this message because you are subscribed to the Google Groups "In-Portal Localization Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-loc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-local?hl=en.

Dmitry A.

unread,
Jan 31, 2011, 1:26:56 PM1/31/11
to in-port...@googlegroups.com
Yes, that I was planning to do.

I can pass multiple "q=SourceText" in a single request ( http://code.google.com/apis/language/translate/v2/using_rest.html#query-params ). The question is how do I know that my total request Size is close to 5KB before I send it?

I can do math using strlen of the PostData property of Curl object to get size in bytes and convert to KB?



DA

Alexander Obuhovich

unread,
Jan 31, 2011, 3:55:05 PM1/31/11
to in-port...@googlegroups.com
You can serialize phrases array and measure it.





DA

--
You received this message because you are subscribed to the Google Groups "In-Portal Localization Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-loc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-local?hl=en.

Dmitry A.

unread,
Feb 2, 2011, 10:27:40 PM2/2/11
to in-port...@googlegroups.com
Here is a new improved version of the translator.


1. It sends 70 phrases per single request

2. It uses 1 SQL to update all 70 translations at once (too bad I have reached API limited to fully test this.


Last results are about 50-60 seconds to translate 3,700 phrases (~53 API requests). The results might vary depending on your host.

I think that If i can get 2. to work - it will be even faster!


Cheers!


DA
GoogleTranslatePrototype-v2.patch

Dmitry A.

unread,
Feb 3, 2011, 10:30:38 PM2/3/11
to in-port...@googlegroups.com
Patch is working good!

Any feed back would be nice.


DA

Dmitry A.

unread,
Feb 6, 2011, 11:10:48 PM2/6/11
to in-port...@googlegroups.com
Hi guys,


This would be the finalized version of Google Translation API.

The following features are done:

1. Ability to mass translate Phrases and Email Events when Language Pack is created from another one (all phrases + events are copied). The proper Locale must be selected for both (source and target) language packs.

2. Ability to get Translation (as suggestion) of any label when editing it via Admin->Labels & Phrases section. The purpose of this is to be able to translate Labels individually.

3. Created "3rd Party API" settings section to store both Google Translate API Url and Google Translate API Key.


Alex, please test and let me know if you are accepting the code. I want to get this in as soon as 5.1.3 so we can start moving forward with translations.



Cheers!

DA



GoogleTranslatePrototype-v3.patch

Dmitry A.

unread,
Feb 8, 2011, 11:08:51 PM2/8/11
to in-port...@googlegroups.com
New task has been created for this:

996: Integrate Google Translation API into Language Translation



Please test and see how it works!

All feedback is welcome.


DA
Reply all
Reply to author
Forward
0 new messages