13

I've just built a custom OpenERP module, let's say /addons/the_meaning_of_life. Now I want to translate it to another language. I now I'm supposed to have an i18n folder containing a .pot and .pofiles. How do I generate these ? It would be nice to have a step-by-step guide.

Daniel Reis
  • 12,944
  • 6
  • 43
  • 71

3 Answers3

17

Ok here what you can do is:

  1. Install your desire lang in your db.
  2. Once you are done with your module development, install module on test server then go to the follwing Wizard Setting(or Configuration) > Translation> Import/Export/Export Translation. Then Choose the module the_meaning_of_life and desire lang. and export it in .po format.
  3. Save that po file then add the translation that you want in the po file. Then you can import back that po file in database or add it under your module under folder /addons/the_meaning_of_life/i18n and it is available with your module.
  4. (only for new modules), you need to have also the "pot" file in the same i18n folder, if you don't yet have it you can generate one by repeating step 2 but without choosing any language. This how you can make available translation for the some lang in your module but if you want use Launchpad translation service then check following url this will guide you using .pot but for that you need project on lp clearly.

Hope this will answer you, Regards

Andres Calle
  • 257
  • 1
  • 3
  • 11
ifixthat
  • 6,137
  • 5
  • 25
  • 42
  • That did it, thank you. Some remarks: the downloaded .po file was ANSI, so I had to save it as UTF-8. I then copied the file, 'pt.po', to the i18n folder and restarted the server. The translations loaded on the server restart. – Daniel Reis Jul 19 '12 at 11:41
  • @DReispt yes right thta is perfect way, you have to keep it in UTF-8 only – ifixthat Jul 19 '12 at 11:44
7

Here is a bash script that I use for this:

$ cat oerp-i18n-module
#!/bin/bash
#
# usage:
# ./oerp-i18n-module <databasename> <module name>
#
# the script will create or update PO files for en, fr, de and es. You
# will need to update the translations (and don't forget bzr add +
# commit)

dirname=$(find src -name $1 | egrep -v '(src/stable)|(src/server)')
install -d ${dirname}/i18n
for lang in en fr de es
do
    python src/server/openerp-server -c config/instance_debug.ini \
              --log-level=error --i18n-export=${lang}.po -l ${lang} \
              -d $1 --modules=$2 > /dev/null 2>&1 
    if [ -f ${dirname}/i18n/${lang}.po ]
    then
        echo merge new translations in ${dirname}/i18n/${lang}.po
        msgmerge -vU --backup=simple ${dirname}/i18n/${lang}.po ${lang}.po
        rm ${lang}.po
    else
        echo put file in ${dirname}/i18n/${lang}.po
        mv ${lang}.po ${dirname}/i18n/
    fi
done

Hope this helps (you may have to edit some paths which are specific to my layout of bzr branches).

gurney alex
  • 13,247
  • 4
  • 43
  • 57
-2

Install your desire lang in your db.

Once you are done with your module development, install module on test server then go to the follwing Wizard Setting(or Configuration) > Translation> Import/Export/Export Translation. Then Choose the module the_meaning_of_life and desire lang. and export it in .po format.

Save that po file then add the translation that you want in the po file. Then you can import back that po file in database or add it under your module under folder /addons/the_meaning_of_life/i18n and it is available with your module.

(only for new modules), you need to have also the "pot" file in the same i18n folder, if you don't yet have it you can generate one by repeating step 2 but without choosing any language. This how you can make available translation for the some lang in your module but if you want use Launchpad translation service then check following url this will guide you using .pot but for that you need project on lp clearly.

Cairnarvon
  • 25,981
  • 9
  • 51
  • 65
Jay
  • 11