[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-i18n-doc
Subject:    Fwd: Translating KDE Docs automatically
From:       Dashamir Hoxha <dashohoxha () gmail ! com>
Date:       2011-05-18 6:31:26
Message-ID: 4DD367BE.2080605 () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


-------- Original Message --------
Subject: Translating KDE Docs automatically
Date: Sun, 15 May 2011 21:44:57 +0200
From: Dashamir Hoxha <dashohoxha@gmail.com>
To: Albert Astals Cid <aacid@kde.org>
CC: Agron Selimaj <as9902613@gmail.com>,  Laurent Dhima
<laurenti@alblinux.net>

Albert,

I am trying to translate the KDE Docs into Albanian
automatically, using Google Translate. The quality
of the translation is not good, but it should be better
than nothing for those who don't know English at all.

I have attached the script 'mtrans.sh' that I am using
for this purpose. I have noticed that not all the tags
should be translated automatically, so only the tags in
'tag_list.txt' are attempted for translation.

The translation is actually done by 'pology/pomtrans.py'.
I tried as well to build my own translation script,
('translate.sh'), however it turned out to be a bit
difficult to process the JSON output from a bash script,
so I went back to 'pomtrans.py'. However I had to edit
it in order to set a google api key and my 'userip'
(otherwise google would refuse to translate).

Now I am trying to check the format of the files, before
commiting them, according to the instructions on:
http://i18n.kde.org/docs/translation-howto/doc-check-the-translation.html
I have checked out the 'scripts/' directory, which contains
'update_xml', but I cannot find neither 'po2xml' nor
'meinproc4'. Can you help me?

Thanks,
Dashamir

-- 
Dashamir Hoxha
GPG: 4F97 4EDE C739 4C3D 361E 16D3 FD06 AA8E 55D5 9B28
In God we trust. Everybody else we verify using GnuPG!


["mtrans.sh" (application/x-shellscript)]

#!/bin/bash
### translate kde docs automatically using google translate

l10n='../l10n-kde4'

### copy docmessage templates (.pot) to language 'sq/'
rm -rf $l10n/sq/docmessages/
cp -a $l10n/templates/docmessages $l10n/sq/

### break connection with svn repository
find $l10n/sq/docmessages/ -name '\.svn' | xargs rm -rf

### translate from google
for f_pot in $(find $l10n/sq/docmessages/ -name '*.pot')
do
  f=${f_pot%%.pot}  ## remove the trailing '.pot'
  echo $f_po

  ### extract the messages that should be translated
  msggrep -X -F -f tag_list.txt -o $f.1.pot $f_pot

  ### translate them
  msginit -l sq --no-translator -i $f.1.pot -o $f.1.po
  ../pology/scripts/pomtrans.py google -m -s en -t sq $f.1.po

  ### fixing some problems
  msgfilter -i $f.1.po -o $f.2.po sed -e 's/&amp; \?\(.\)\([^;]\+\);/\&\l\1\2;/'

  ### create the PO file by merging with the translated messages
  msgmerge -o $f.3.po $f.2.po $f_pot

  ### copy the msgid for the tags that were not translated
  msgen -o $f.po $f.3.po

  ### cleanup
  rm $f_pot $f.1.pot $f.1.po $f.2.po $f.3.po
done


### check for errors
for f in $(find sq/docmessages/ -name '*.po'); do echo $f; msgfmt --check $f; done
for f in $(find sq/docmessages/ -name '*.po'); do echo $f; ../scripts/msgfmt-test.sh $f; done
pofilter -i $check_dir -o ${check_dir}_err \
         --kde -t accelerators -t escapes -t nplurals -t tab -t xmltags


["tag_list.txt" (text/plain)]

Tag: action
Tag: contrib
Tag: emphasis
Tag: entry
Tag: para
Tag: simpara
Tag: title
Tag: subtitle
Tag: interface
Tag: link
Tag: listitem
Tag: literal
Tag: literallayout
Tag: refpurpose
Tag: menuchoice
Tag: mousebutton
Tag: phrase
Tag: screeninfo
Tag: primary
Tag: quote
Tag: refentrytitle
Tag: remark
Tag: secondary
Tag: see
Tag: seealso
Tag: seg
Tag: segtitle
Tag: tertiary


["translate.sh" (application/x-shellscript)]

#!/bin/bash

str="$@"
translate_service='https://ajax.googleapis.com/ajax/services/language/translate'
langpair='en|sq'
key='ABQIAAAATVjsHKr9CKp5srvxjOihrRTRvGtAORIjNbNNQzUDW02w2WWD0xQRv_B2qAkS0E8qIJwHOfpGEiH7QQ'
userip='109.69.6.250'
referer='http://l10n.kde.org/'

function translate
{
  str="$@"
  curl --url $translate_service --referer "$referer" --silent --show-error \
       --get --data-urlencode "v=1.0" --data-urlencode "langpair=$langpair" \
       --data-urlencode "q=t!!!$str!!!" --data-urlencode "key=$key" \
       --data-urlencode "userip=$userip" \
    | sed -e 's/.*":"t!!!\(.*\)!!!"}, .*/\1/'
}

case "$#" in
  0) while read line; do translate $line; done
     ;;
  *) translate "$@"
     ;;
esac

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic