From 8ac392873b1ae5979fdee845d7b03843fe9b6bf8 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 9 Jul 2015 11:27:04 +0200 Subject: [PATCH] [FIX] tools: export translations of models.py When exporting the translations, the terms stored in individual files outside of addons folders (e.g. openerp/models.py) needs to be scanned as well and added in base translations. Some folders like osv and report were enough to add these files but with the new api moving the ORM to openerp folder, a non-recusrive scan needs to be added. Fixes #7482 --- openerp/tools/translate.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py index bdf31f85eeb..d3d1fdbf848 100644 --- a/openerp/tools/translate.py +++ b/openerp/tools/translate.py @@ -843,16 +843,19 @@ def trans_generate(lang, modules, cr): lambda m: m['name'], registry['ir.module.module'].search_read(cr, uid, [('state', '=', 'installed')], fields=['name'])) - path_list = list(openerp.modules.module.ad_paths) + path_list = [(path, True) for path in openerp.modules.module.ad_paths] # Also scan these non-addon paths - for bin_path in ['osv', 'report' ]: - path_list.append(os.path.join(config.config['root_path'], bin_path)) + for bin_path in ['osv', 'report', 'modules', 'service', 'tools']: + path_list.append((os.path.join(config.config['root_path'], bin_path), True)) + # non-recursive scan for individual files in root directory but without + # scanning subdirectories that may contain addons + path_list.append((config.config['root_path'], False)) _logger.debug("Scanning modules at paths: %s", path_list) def get_module_from_path(path): - for mp in path_list: - if path.startswith(mp) and os.path.dirname(path) != mp: + for (mp, rec) in path_list: + if rec and path.startswith(mp) and os.path.dirname(path) != mp: path = path[len(mp)+1:] return path.split(os.path.sep)[0] return 'base' # files that are not in a module are considered as being in 'base' module @@ -887,7 +890,7 @@ def trans_generate(lang, modules, cr): finally: src_file.close() - for path in path_list: + for (path, recursive) in path_list: _logger.debug("Scanning files of modules at %s", path) for root, dummy, files in osutil.walksymlinks(path): for fname in fnmatch.filter(files, '*.py'): @@ -906,6 +909,9 @@ def trans_generate(lang, modules, cr): for fname in fnmatch.filter(files, '*.xml'): babel_extract_terms(fname, path, root, 'openerp.tools.translate:babel_extract_qweb', extra_comments=[WEB_TRANSLATION_COMMENT]) + if not recursive: + # due to topdown, first iteration is in first level + break out = [] # translate strings marked as to be translated