← Back to team overview

oship-dev team mailing list archive

French translation is ready (NOT) & ADL_to_Python suggestion

 

Hi all:
  This weekend I started to work on the French translation and, to speed
the things up a bit, I:
(1) downloaded the French .PO file from the translations.launchpad.net
(a.k.a. Rosetta) server;
(2) did a "machine traslation" (using "Google Translations" through the
little Python script below) on all its messages and
(3) uploaded the resulting .PO file back to the server.

-----snip-----
#!/usr/bin/python

def translate(text,fromLang='en',toLang='fr'):
    import urllib
    import re
    urllib.FancyURLopener.version='Mozilla/5.0 (X11; U; Linux i686; en-
US; rv:1.9.0.1) Gecko/2008070400 SUSE/3.0.1-0.1 Firefox/3.0.1'
post_params=urllib.urlencode({'langpair':'%s|%s'%(fromLang,toLang),'text':text,'ie':'UTF8','oe':'UTF8'})
page=urllib.urlopen('http://translate.google.com/translate_t',post_params)
    content=page.read(); page.close()
    match=re.search('<div id=result_box dir="ltr">(.*?)</div>',content)
    value=match.groups()[0]
html2text={'<br>':'\n','&#39;':"'",'&amp;':'&','&lt;':'<','&gt;':'>'}
    for key in html2text.keys():
        value=value.replace(key,html2text[key])
    return value

if __name__ == '__main__':
    import sys
    import polib
    #sys.argv.append('test.po')
    po=polib.pofile(sys.argv[1])
    for entry in po:
        print entry.msgid
        if entry.msgstr=='':
            entry.msgstr=translate(entry.msgid,'en','fr')
            #entry.flags.append('fuzzy')
            #print '[fuzzy]',
        print entry.msgstr
    po.save()
-----snip-----

  [I am putting the script here since other translators may find it
useful (the only extra library needed is polib: easy_install polib).]

  Unfortunately, I could not find a way to upload my messages already
marked as "fuzzy" (see the 2 commented lines, near the end of the
script); the Rosetta server simply discarded them. That's why all French
translations are temporarily marked as "good", here:
https://translations.launchpad.net/oship/trunk/+pots/oship . The first
~100 messages (as well as most of the 1-, 2- an 3-word ones) are already
OK, but the rest are in fact "false positives" that I will be reviewing
later on, so be warned.

  Now, concerning the "adl2py" experimental branch: instead of
"grokifing" the .ADL files, maybe it'll be enough to convert them into
an intermediary format that Zope/Grok already knows how to handle (e.g.
XML or, better yet, JSON: http://www.json.org and:
http://en.wikipedia.org/wiki/JSON). What do you think?

  Best regards,
Roberto.
-- 
This message was sent from Launchpad by the user
Roberto Siqueira (https://launchpad.net/~siqueira-lmtg)
using the "Contact this team" link on the OSHIP Development Team team page.
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople



Follow ups