How to translate an OpenERP module?

老子叫甜甜 提交于 2019-12-03 16:12:43

问题


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.


回答1:


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




回答2:


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).




回答3:


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.



来源:https://stackoverflow.com/questions/11556502/how-to-translate-an-openerp-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!