Help

4

Correct way to add translations to Odoo through .po files?

Hi everybody

I've been trying and failing at translations for hours now. 
Could anybody tell me the correct way to add translations to Odoo through the .po files?
So far I've tried adding them to an existing .po file, made a new .po file, loaded translations again, removed the language again, hard refresh, ...

Under addons/l10n_be there is a file named fiscal_templates.xml and I'm trying to translate these records in Dutch:

    <record id="fiscal_position_template_1" model="account.fiscal.position.template">
            <field name="name">Régime National</field>
            <field name="chart_template_id" ref="l10nbe_chart_template"/>
    </record>
    <record id="fiscal_position_template_2" model="account.fiscal.position.template">
            <field name="name">Régime Extra-Communautaire</field>
            <field name="chart_template_id" ref="l10nbe_chart_template"/>
    </record>

    <record id="fiscal_position_template_3" model="account.fiscal.position.template">
            <field name="name">Régime Intra-Communautaire</field>
            <field name="chart_template_id" ref="l10nbe_chart_template"/>
    </record>

When the user his language is in Dutch I want them to be translated to Dutch too so I've added translations under l10n_be/i18n_extra/nl_BE.po and added a custom .po file (nl.po). Both files contain the same custom translation values:

# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_be
# Yenthe, 2015.
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-14 13:31+0000\n"
"PO-Revision-Date: 2013-03-14 16:41+0100\n"
"Last-Translator: Yenthe \n"
"Language-Team: \n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.5.4\n"

#. module: l10n_be
#: model:account.fiscal.position,name:l10n_be.fiscal_position_template_1
msgid "Régime National"
msgstr "Nationaal regime"

#. module: l10n_be
#: model:account.fiscal.position,name:l10n_be.fiscal_position_template_4
msgid "Régime National - Cocontractant"
msgstr "Nationaal regime - Medecontractant"

#. module: l10n_be
#: model:account.fiscal.position,name:l10n_be.fiscal_position_template_2
msgid "Régime Extra-Communautaire"
msgstr "Extra-communautair regime"

#. module: l10n_be
#: model:account.fiscal.position,name:l10n_be.fiscal_position_template_3
msgid "Régime Intra-Communautaire"
msgstr "Intra-Communautair regime"

#. module: l10n_be
#: model:account.fiscal.position.template,name:l10n_be.fiscal_position_template_1
msgid "Régime National"
msgstr "Nationaal regime"

#. module: l10n_be
#: model:account.fiscal.position.template,name:l10n_be.fiscal_position_template_4
msgid "Régime National - Cocontractant"
msgstr "Nationaal regime - Medecontractant"

#. module: l10n_be
#: model:account.fiscal.position.template,name:l10n_be.fiscal_position_template_2
msgid "Régime Extra-Communautaire"
msgstr "Extra-communautair regime"

#. module: l10n_be
#: model:account.fiscal.position.template,name:l10n_be.fiscal_position_template_3
msgid "Régime Intra-Communautaire"
msgstr "Intra-Communautair regime"

However when I look at the fiscal positions they are still in French and I cannot find my translations anywhere in Odoo.
I've tried -u and -i to update the module, I've tried adding a sequence to the __openerp__.py etcetc but nothing seems to load in the new translations

So, what am I missing / doing wrong and how do I get my custom translations in Odoo through the .po files?

With kind regards
Yenthe

2 Comments
Avatar
Discard
Avatar
gunnar
-

hi Yenthe. I want to add a translation to another l10n module but this does not even have template .po files. Do you happen to know how you can generate those (looks to me as this might be an automated process). https://www.odoo.com/forum/help-1/question/v8-how-can-i-generate-translation-po-files-for-a-module-72608

Avatar
Mital Vaghani
-

Hello Yenthe Van Ginneken,

It's mandatory to have translation source terms must be available in .pot file?

3 Answers
7
Avatar
akram
Best Answer

Follow below steps:

1) Go to

Settings ‣ Translations ‣ Import / Export ‣ Export Translations

leave the language to the default (new language/empty template) # DO NOT CHANGE THIS

select the PO File format

select your module

click Export and download the file

2) Add your translation terms in the downloaded file. i.e. msgstr "" section depending on your translation language

3) change the filename to language_iso_code.po

e.g. for portugese => pt.po

4) create i18n folder under your module and add po file in it.

5) restart Odoo

6) Go to:

Settings ‣ Translations ‣ Load a Translation

select translation language (in my eg. Portugese)

make sure you check this : Overwrite Existing Terms

click LOAD.

DONE

1 Comment
Avatar
Discard

--update=all helped me. updating or restarting the server did not work for me. But still this is very helpful. Thanks Akram.

0
Avatar
Alp ŞEBER
Best Answer

I was trying same during entire day and it was not showing all terms in translated language although everything were translated in PO file.

This morning, i went to settings, translations and translated terms and searched for an item (from old source, advanced) which had translation but not showing. 

I changed the translation, made the type view from object, saved and stop/start the server.

somehow, i guess this triggered the system to load the translation again since everything became translated. After i reverted back the field i broke with type to object.

it is weird but worked for me. 

Avatar
Discard
0
Avatar
Kalpana Hemnani
Best Answer

Hello Yenthe,

No need to update module, you just need to load translation. go to Settings/ Translations / Load a Translation.

By clicking on that wizard select Language to translate and check Overwrite Existing Terms.

EDIT: You have to made field Translatable. add an attribute in fields translate=True.

Hope this helps.

4 Comments
Avatar
Discard

Thanks for the answer Kalpana. I've tried this method but it doesn't work either, translations don't get updated and are not showing up anywhere in Odoo.

The Translatable you're talking about won't have any effect by the way? My records are defined in XML.

Avatar
Pascal Tremblay
-

When we click on « Load a translation », it means that Odoo checks in all the addon files to search .po files of the chosen language and overwrite the existing terms in place for this language? Is it possible to load only ONE .po file at a time instead of ALL the .po files at a time???

Avatar
Girija Subramaniyan
-

While clicking Overwrite existing comands getting error !

Error Msg:

File not imported due to format mismatch or a malformed file. (Valid formats are .csv, .po, .pot)

Technical Details:

there is no unique or exclusion constraint matching the ON CONFLICT specification