Modified translations in a base_lang_code.po file are not updated

Bug #1166776 reported by Enrico Ganzaroli
54
This bug affects 10 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
OpenERP Publisher's Warranty Team

Bug Description

Steps to reproduce the behaviour:

1) Create the i18n/base_lang_code.po for a module containing at least one translation.
2) Update the module (importing the translation file).
3) Modify a translation already imported in the file i18n/base_lang_code.po.
4) Update the module.

The original translation will not be updated.

server/openerp/addons/base/ir/ir_translation.py,402

    # Step 1: for sub-languages, load base language first (e.g. es_CL.po is loaded over es.po)
    if base_lang_code:
        base_trans_file = openerp.modules.get_module_resource(module_name, 'i18n', base_lang_code + '.po')
        if base_trans_file:
            _logger.info('module %s: loading base translation file %s for language %s', module_name, base_lang_code, lang)
            tools.trans_load(cr, base_trans_file, lang, verbose=False, module_name=module_name, context=context)
            context['overwrite'] = True # make sure the requested translation will override the base terms later

Note that context['overwrite'] is True only after the base language file (i.e. es.po) has been loaded.

server/openerp/addons/base/ir/ir_translation.py,66

    self._overwrite = context.get('overwrite', False)

server/openerp/addons/base/ir/ir_translation.py,120

    # Step 2: update existing (matching) translations
    if self._overwrite:
        cr.execute("""UPDATE ONLY %s AS irt
            SET value = ti.value,
            state = 'translated'
            FROM %s AS ti
            WHERE %s AND ti.value IS NOT NULL AND ti.value != ''
            """ % (self._parent_table, self._table_name, find_expr))

Here self._overwrite should be True in order to update existing translations.

TEMPORARY FIX

server/openerp/addons/base/ir/ir_translation.py,66

-- self._overwrite = context.get('overwrite', False)
++ self._overwrite = context.get('overwrite', True)

Tags: maintenance
Revision history for this message
Karel Marissens (karel-marissens) wrote :

Thanks for the temporary fix.

This should probably be fixed by creating a context in the code that loads the modules, I'm guessing at the following line in loading.py:
            # Update translations for all installed languages
            modobj.update_translations(cr, SUPERUSER_ID, [module_id], None) <-- add context={'overwrite': True} here

Changed in openobject-server:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Numérigraphe (numerigraphe) wrote :

Not sure that would be a good idea, since we allow users to change translations from the GUI.
Lionel Sausin.

Revision history for this message
Harri Luuppala (harri-luuppala) wrote :

Could it be a parameter in the 'opener-server.conf' file.

I.e.
# LP = use translation fro LP or User = user defined translations
Launchpad_Translation=LP

description: updated
Revision history for this message
Yann Papouin (yann-papouin) wrote :

For the record:
The correct way is to pass "--i18n-overwrite" on the server command line and apply the "should it be" fix
https://bugs.launchpad.net/openobject-server/+bug/1319285

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.