Adapt the translation exporter to the multi-path addons.

bzr revid: p_christ@hol.gr-20090602113507-1jyjcw5uuz3e7kfp
This commit is contained in:
P. Christeas 2009-06-02 14:35:07 +03:00
parent a8174908dc
commit e39b6bb595
1 changed files with 17 additions and 5 deletions

View File

@ -568,11 +568,23 @@ def trans_generate(lang, modules, dbname=None):
push_translation(module, 'model', name, xml_name, encode(trad))
# parse source code for _() calls
def get_module_from_path(path):
relative_addons_path = tools.config['addons_path'][len(tools.config['root_path'])+1:]
if path.startswith(relative_addons_path) and (os.path.dirname(path) != relative_addons_path):
path = path[len(relative_addons_path)+1:]
return path.split(os.path.sep)[0]
def get_module_from_path(path,mod_paths=None):
if not mod_paths:
# First, construct a list of possible paths
def_path = os.path.abspath(os.path.join(tools.config['root_path'], 'addons')) # default addons path (base)
ad_paths= map(lambda m: os.path.abspath(m.strip()),tools.config['addons_path'].split(','))
mod_paths=[def_path]
for adp in ad_paths:
mod_paths.append(adp)
if not adp.startswith('/'):
mod_paths.append(os.path.join(def_path,adp))
elif adp.startswith(def_path):
mod_paths.append(adp[len(def_path)+1:])
for mp in mod_paths:
if 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
modobj = pool.get('ir.module.module')