Comment 0 for bug 1166776

Revision history for this message
Enrico Ganzaroli (enrico-gz) wrote :

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)