[MERGE] tools.translate, module: load generic PO files before specific ones (e.g fr.po before fr_BE.po)
bzr revid: odo@openerp.com-20101229145313-7v7rv3ntmqehzdyi
This commit is contained in:
commit
3ecea6df63
|
@ -495,15 +495,23 @@ class module(osv.osv):
|
|||
for lang in filter_lang:
|
||||
iso_lang = tools.get_iso_codes(lang)
|
||||
f = addons.get_module_resource(mod.name, 'i18n', iso_lang + '.po')
|
||||
context2 = context and context.copy() or {}
|
||||
if f and '_' in iso_lang:
|
||||
iso_lang2 = iso_lang.split('_')[0]
|
||||
f2 = addons.get_module_resource(mod.name, 'i18n', iso_lang2 + '.po')
|
||||
if f2:
|
||||
logger.info('module %s: loading base translation file %s for language %s', mod.name, iso_lang2, lang)
|
||||
tools.trans_load(cr.dbname, f2, lang, verbose=False, context=context)
|
||||
context2['overwrite'] = True
|
||||
# Implementation notice: we must first search for the full name of
|
||||
# the language derivative, like "en_UK", and then the generic,
|
||||
# like "en".
|
||||
if (not f) and '_' in iso_lang:
|
||||
f = addons.get_module_resource(mod.name, 'i18n', iso_lang.split('_')[0] + '.po')
|
||||
iso_lang = iso_lang.split('_')[0]
|
||||
f = addons.get_module_resource(mod.name, 'i18n', iso_lang + '.po')
|
||||
if f:
|
||||
logger.info('module %s: loading translation file for language %s', mod.name, iso_lang)
|
||||
tools.trans_load(cr.dbname, f, lang, verbose=False, context=context)
|
||||
logger.info('module %s: loading translation file (%s) for language %s', mod.name, iso_lang, lang)
|
||||
tools.trans_load(cr.dbname, f, lang, verbose=False, context=context2)
|
||||
elif iso_lang != 'en':
|
||||
logger.warning('module %s: no translation for language %s', mod.name, iso_lang)
|
||||
|
||||
|
|
|
@ -935,7 +935,7 @@ def trans_load_data(db_name, fileobj, fileformat, lang, lang_name=None, verbose=
|
|||
args.append(('res_id', '=', dic['res_id']))
|
||||
ids = trans_obj.search(cr, uid, args)
|
||||
if ids:
|
||||
if context.get('overwrite'):
|
||||
if context.get('overwrite') and dic['value']:
|
||||
trans_obj.write(cr, uid, ids, {'value': dic['value']})
|
||||
else:
|
||||
trans_obj.create(cr, uid, dic)
|
||||
|
|
Loading…
Reference in New Issue