diff options
| author | Vo Minh Thu <vmt@openerp.com> | 2010-12-27 14:58:00 +0100 |
|---|---|---|
| committer | Vo Minh Thu <vmt@openerp.com> | 2010-12-27 14:58:00 +0100 |
| commit | 8f8001d5f0412c811233b8e68570f455e0df94ab (patch) | |
| tree | 7ef254a7acc6856d9764a32e9c47a78179557731 /bin/addons/base/module/module.py | |
| parent | 9b0e39da8c352fa084c074ee3335db0a53dce38e (diff) | |
[IMP] translate: load language xx before xx_XX and overwrite only when a translation is available.
bzr revid: vmt@openerp.com-20101227135800-qwvsk4xwhzrjg6yf
Diffstat (limited to 'bin/addons/base/module/module.py')
| -rw-r--r-- | bin/addons/base/module/module.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py index ba79dea4e13..08ae911e545 100644 --- a/bin/addons/base/module/module.py +++ b/bin/addons/base/module/module.py @@ -495,6 +495,14 @@ 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: + f2 = addons.get_module_resource(mod.name, 'i18n', iso_lang.split('_')[0] + '.po') + iso_lang2 = iso_lang.split('_')[0] + if f2: + logger.info('module %s: loading translation file for language %s', mod.name, iso_lang2) + 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". @@ -503,7 +511,7 @@ class module(osv.osv): iso_lang = iso_lang.split('_')[0] 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) + 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) |
