2

I want to create an OpenERP l10n module (chart of accounts) for my country. I need this translated into two languages. In account_chart.xml I put words in English. So, words are static. How can I translate the value for the name of an account in the following example:

<record id="chart01" model="account.account.template">
     <field name="code">01</field>
     <field name="parent_id" ref="chart0"/>
     <field name="type">view</field>
     <field name="user_type" ref="account.data_account_type_view"/>
     <field name="name">Expenses</field>
  </record>

For example I want to translate word Expenses. I don't know how to configure this in *.po files. Can somebody show me some example? Cheers

odony
  • 4,027
  • 17
  • 27

2 Answers2

4

Good question! The official reference for creating OpenERP localization modules is this page of the documentation. However it does not explain how to translate a localization module, because ironically, localization modules seldom need to be translated.

A bit of context: Contrasting with the way generic OpenERP modules are written, the localization modules of monolingual countries have the names of the taxes, G/L accounts, etc. directly defined in the country's language, rather than defined in English and then translated in .po files. In fact the OpenERP models for localization data (tax templates, account templates, etc.) have the translation flag voluntarily turned off. The reason is simple: if the names of these items were always translatable, they would appear in the list of terms to translate for all OpenERP translations! Imagine the mess if each translator team was asked to translate in their language the names of all taxes and G/L account of the world, something perfectly useless.

Belgium being one of the lucky multilingual countries, there is however an (experimental) way to make your chart of accounts translatable.

The solution is threefold:

  1. Your l10n_xx module must depend on the l10n_multilang module. This small module turns the translation flag on for most of the fields that you would want to translate in a chart of account. It also adds a special spoken_languages field on the Chart of Accounts Template model, and will automatically try to load the corresponding translations when that chart of accounts is installed (provided these languages have been installed previously in the same database)

  2. You must add a spoken_languages field to the XML declaration of your chart of accounts. Its value must be a semicolon-separated list of language codes, where each code is the value of the code field of that language when it is installed in OpenERP. You can see the list of all available language codes in the source. For example if you wanted to add a French and a German translation for your Chart of Accounts, you could use the following value XML field:
    <field name="spoken_languages">fr_FR;de_DE</field>

  3. Last but not least, you need to actually create the translation files, similarly to what you'd do for any other OpenERP module. You should ideally use English names in the master data files, arguably awkward if English is not one of the official country languages, so using one of the official languages of your country will work too. Then export the l10n_xx.pot PO Template file by using the translation export wizard inside OpenERP (select your module and no language in the export wizard), and put it in the l10n_xx/i18n/ directory of your module. Finally you can create the initial translations by duplicating the l10n_xx.pot for each desired language (e.g. fr.po for French, etc.), and filling in the translations using a PO Editor such as Poedit.
    Check out the documentation about OpenERP translations for more details on the PO/POT file format and organization, as well as DReispt's related question (already mentioned).

After performing the above steps, the translations should be loaded automatically in each database where you install your localization module (but make sure to install all the relevant languages before installing the Chart of Account)

This technique is still a bit experimental, so don't hesitate to report bugs if it doesn't seem to work as described.

PS: Obviously all of this should be mentioned in the official OpenERP localization documentation, so if someone feels like doing it, remember that the documentation is open and anyone can directly contribute to it ;-)

Community
  • 1
  • 1
odony
  • 4,027
  • 17
  • 27
  • Working, but one important thing is missing. l10n_multilang create translation only for *account.account.template*, not also for *account.account*. Maybe is problem in [source](http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/view/head:/l10n_multilang/l10n_multilang.py). At line 128 *_process_accounts_translations* calls process_translations with force_write=True. Because **not** at line 68, *account.account* translation is never been created. I remove **not** and get translations for *account.account*. Are there some negative consequences for these changes in *l10n_multilang.py*? – Nikola Stevanovic Oct 19 '12 at 09:50
0

My experience is that the .po file exported by OpenERP includes the text in data XML files. I think that, in order for the name field values to be included in the .po file, it needs to be translatable, that is, have translated=True in it's model (account.account.template is this case).

You might also find the How to translate an OpenERP module? question useful.

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