[REVERT] tools.translate: undo rev 4874 refactoring and renaming `trans_parse_view`, was meant for trunk

rev 4874 = rev-id xmo@openerp.com-20130306095720-3277aw0rq9pzpsw4

bzr revid: odo@openerp.com-20130307164558-alvl7hcov2uhqxbw
This commit is contained in:
Olivier Dony 2013-03-07 17:45:58 +01:00
parent 65e7ad2aa4
commit 527ef066dd
1 changed files with 17 additions and 10 deletions

View File

@ -533,20 +533,27 @@ def trans_parse_rml(de):
res.extend(trans_parse_rml(n))
return res
TRANSLATABLE_VIEW_ATTRS = ['string', 'help', 'sum', 'confirm', 'placeholder']
def extract_translatable_view_strings(de):
def trans_parse_view(de):
res = []
if not isinstance(de, SKIPPED_ELEMENT_TYPES) and de.text and de.text.strip():
res.append(de.text.strip().encode("utf8"))
if de.tail and de.tail.strip():
res.append(de.tail.strip().encode("utf8"))
for attr in TRANSLATABLE_VIEW_ATTRS:
if de.get(attr):
res.append(de.get(attr).encode('utf8'))
if de.tag == 'attribute' and de.get('name') == attr and de.text:
res.append(de.text.encode('utf8'))
if de.tag == 'attribute' and de.get("name") == 'string':
if de.text:
res.append(de.text.encode("utf8"))
if de.get("string"):
res.append(de.get('string').encode("utf8"))
if de.get("help"):
res.append(de.get('help').encode("utf8"))
if de.get("sum"):
res.append(de.get('sum').encode("utf8"))
if de.get("confirm"):
res.append(de.get('confirm').encode("utf8"))
if de.get("placeholder"):
res.append(de.get('placeholder').encode("utf8"))
for n in de:
res.extend(extract_translatable_view_strings(n))
res.extend(trans_parse_view(n))
return res
# tests whether an object is in a list of modules
@ -666,7 +673,7 @@ def trans_generate(lang, modules, cr):
if model=='ir.ui.view':
d = etree.XML(encode(obj.arch))
for t in extract_translatable_view_strings(d):
for t in trans_parse_view(d):
push_translation(module, 'view', encode(obj.model), 0, t)
elif model=='ir.actions.wizard':
service_name = 'wizard.'+encode(obj.wiz_name)
@ -703,7 +710,7 @@ def trans_generate(lang, modules, cr):
arch = result['arch']
if arch and not isinstance(arch, UpdateableStr):
d = etree.XML(arch)
for t in extract_translatable_view_strings(d):
for t in trans_parse_view(d):
push_translation(module, 'wizard_view', name, 0, t)
# export button labels