#464 Google Translate API Addition to Language Tools

closed-accepted
5
2008-10-09
2008-03-22
Ezz
No

Hi

I have used the Google Language API to add in a link in editlang.php to allow a translator to see how google translates a sentence before entering their own version.

This is an initial version and there are some routes I could go down in improving it so I would like some feedback before I do that.

If this patch is accepted it would help translators a lot since you can get a half decent translation with a quick click.

Cheers
Ezz

Discussion

  • Ezz
    Ezz
    2008-03-22

    Logged In: YES
    user_id=1074077
    Originator: YES

    I should also mention there is also a link at the bottom of the page to commit google translated entries, which posts to the editlang_edit.php page multiple times using ajax.

    So in essence it is a two step process, first select the entries you want to edit, click the Google Translate link, commit the changes and once the page is reloaded you would then edit the mistranslated entries by hand.

     
  • Logged In: YES
    user_id=1946672
    Originator: NO

    Seems to works good with polish translations

    But there is one issue. When clicking "Commit Google translated changes" several times language records are duplicated.

     
  • Ezz
    Ezz
    2008-05-31

    Logged In: YES
    user_id=1074077
    Originator: YES

    Ok thanks wooc, I'll take a look - should be easy to fix.

     
  • Logged In: YES
    user_id=1946672
    Originator: NO

    I found other bug. If in translation is a double qute ", should be preceded by \

     
  • Logged In: YES
    user_id=1946672
    Originator: NO

    Ezz, could you solved this bugs? I like this patch and I'll add this to SVN if these bugs are solved.

     
  • Ezz
    Ezz
    2008-06-25

    Logged In: YES
    user_id=1074077
    Originator: YES

    Fantastic. Sorry - I got married, moved country and changed jobs!

    I'll do it now ;)

     
  • Ezz
    Ezz
    2008-06-26

    Logged In: YES
    user_id=1074077
    Originator: YES

    I've fixed everything but I found another problem when theres a single quote in the translation... Needs some more work tomorrow to fix it.

     
  • Ezz
    Ezz
    2008-06-27

    Logged In: YES
    user_id=1074077
    Originator: YES

    I've hit a problem getting the utf8 escape javascript function to work nicely with php urldecode... They are opposite functions but they don't work in the same way. I'll look at this more over the weekend.

     
  • Ezz
    Ezz
    2008-06-28

    Logged In: YES
    user_id=1074077
    Originator: YES

    Ok I've fixed it - it turns out all i needed was to escape the ampersands in javascript calls to the commit page. I've also fixed the posting functions through ajax.

    I tested this with arabic so it should work with rtl as well as ltr.
    File Added: GoogleTranslate_v0.2.patch

     
  • Ezz
    Ezz
    2008-06-29

    Logged In: YES
    user_id=1074077
    Originator: YES

    I've updated it to remove the postback when committing all the google translated rows.

    Also added a feature to allow each row to be commited, so you can click translate, click commit, and then click to edit the text. This should speed up translation by an order of magnitude.

    I've fixed up the indenting in editlang.php and made the editlang_edit.php look up the correct row in the lang file if its not passed a reference to the line. This is necessary since we are now updating using ajax rather than postback.

    Also improved one or two variable names ($z to $ls01) to make it more standardized and clear.
    File Added: GoogleTranslate_v0.3.patch

     
  • Logged In: YES
    user_id=1946672
    Originator: NO

    Congratulations!

    I tested this and I have suggestion that characters like < or > should not be replaced with &lt; and &gt;
    If in text are someting like this <b>#GLOBALS[SOMETHING]#</b> or ~#pgv_lang[move_mediadirs]#~ the translator should not to change this.

    If in text qoute or double qoute character are proceded by \ the translator should leave this as \' or \"

     
  • Ezz
    Ezz
    2008-07-12

    Vesion 4, fixed angled bracket problem and attempted to improve quoting

     
  • Ezz
    Ezz
    2008-07-12

    Logged In: YES
    user_id=1074077
    Originator: YES

    Hey wooc,

    Thanks for testing again.

    I thought I'd fixed the &lt; &gt; thing - forgot to remove a line from the javascript. It now records < and > properly.

    The second thing is very tough, I'd like to be able to do it but it means I have to break up the sentences and translate them each individually then recombine them. If I find some time I will do it. I meant this tool to be a quick and dirty translation mechanism which will give a hint to the translator rather than providing a complete translation.

    I've tested the final thing, I think I'm doing the right thing but I can't be sure... since google translate messes around with the text, xml and html I can't guarantee the output will be correct!
    File Added: GoogleTranslate_v0.4.patch

     
  • Logged In: YES
    user_id=1946672
    Originator: NO

    Ezz,
    Could you help us?

    RE: Link to Google Translate (New)
    By: Gerry Kroll (canajun2eh) - 2008-08-06 21:51
    The translate() Javascript function isn't being executed.

    I added an alert() right at the beginning of the translate() function, and the Alert isn't being shown. Replacing the call to the translate() fnction with an alert() produces the expected alert, indicating that the onclick() is working.

    It's possible that there's an error somewhere in the translate.js file that's causing Firefox to ignore the entire script file.

    RE: Link to Google Translate (New)
    By: Gerry Kroll (canajun2eh) - 2008-08-07 03:01
    Łukasz:
    Sorry,.... "It doesn't work on my site".

    I moved the JS function translate() into a separate script file that I then loaded editlang.php exactly the same way translate.js is loaded. I changed function translate() to add an alert() at the beginning.

    When I clicked on the Google translate link, the alert showed as expected but nothing else happened. The scripts were put back the way they are in SVN, and then I added the same alert() to function translate() in translate.js. The alert did not show.

     
  • Ezz
    Ezz
    2008-08-11

    Logged In: YES
    user_id=1074077
    Originator: YES

    Hi Wooc,
    Sure I will get on it. I'm on my honeymoon at the moment, but I will be back on Thursday :)

     
  • Logged In: YES
    user_id=1946672
    Originator: NO

    Thanks. On my site translate to polish works good. Gerry have problems with translate to german.

     
  • Ezz
    Ezz
    2008-08-26

    Logged In: YES
    user_id=1074077
    Originator: YES

    Hey wooc, canajun2eh

    Sorry it took so long, I updated to the latest code this evening in trunk and attempted to edit the German language using both Firefox and IE and it works... I couldn't get it to show me any errors.

    There should be some javascript errors if the js file wasn't loaded, you can get hold of them in Firefox through the Tools menu, and then click Error Console. Also installing the Firebug addon (https://addons.mozilla.org/en-US/firefox/addon/1843) will help tremendously as it gives detailed errors (click the red cross in the bottom right hand corner of Firefox)

    Are you using Firefox or IE, what version?
    Can you attach your js file, maybe it didn't download properly?

     
    • assigned_to: nobody --> wooc
     
    • status: open --> open-accepted
     
    • status: open-accepted --> closed-accepted