[MERGE] Call the translation services, check the requested translation if not translation then laod it from internal file resource will support when web running in non embedded mode

bzr revid: jam@tinyerp.com-20120716062251-ub62cqfwl2n15zh4
This commit is contained in:
Jigar Amin - OpenERP 2012-07-16 11:52:51 +05:30
commit d23af2550d
1 changed files with 18 additions and 18 deletions

View File

@ -353,25 +353,25 @@ class WebClient(openerpweb.Controller):
langs = lang.split(separator)
langs = [separator.join(langs[:x]) for x in range(1, len(langs) + 1)]
transs = {}
proxy = req.session.proxy("translation")
messages = proxy.load(req.session._db, mods, langs, "web")
for addon_name in mods:
transl = {"messages":[]}
transs[addon_name] = transl
addons_path = openerpweb.addons_manifest[addon_name]['addons_path']
for l in langs:
f_name = os.path.join(addons_path, addon_name, "i18n", l + ".po")
if not os.path.exists(f_name):
continue
try:
with open(f_name) as t_file:
po = babel.messages.pofile.read_po(t_file)
except Exception:
continue
for x in po:
if x.id and x.string and "openerp-web" in x.auto_comments:
transl["messages"].append({'id': x.id, 'string': x.string})
return {"modules": transs,
"lang_parameters": lang_obj}
if not messages[addon_name]['messages']:
addons_path = openerpweb.addons_manifest[addon_name]['addons_path']
for l in langs:
f_name = os.path.join(addons_path, addon_name, "i18n", l + ".po")
if not os.path.exists(f_name):
continue
try:
with open(f_name) as t_file:
po = babel.messages.pofile.read_po(t_file)
except Exception:
continue
for x in po:
if x.id and x.string and "openerp-web" in x.auto_comments:
messages[addon_name]["messages"].append({'id': x.id, 'string': x.string})
return {"modules": messages,
"lang_parameters": lang_obj}
@openerpweb.jsonrequest
def version_info(self, req):