Commit e6e026d2 authored by Tomáš Peterka's avatar Tomáš Peterka

erp5_web_renderjs_ui: Translation is resistant to non-existing Web Page references

parent 66dae2cb
...@@ -12,10 +12,21 @@ tmp_re = re.compile(r"""/[{}]/g, """"") ...@@ -12,10 +12,21 @@ tmp_re = re.compile(r"""/[{}]/g, """"")
translate_word = [] translate_word = []
omitted = 0
processed = 0
longest_omitted_reference = ''
web_page_list = context.Base_getListFileFromAppcache(only_html=1) web_page_list = context.Base_getListFileFromAppcache(only_html=1)
for web_page in web_page_list: for web_page in web_page_list:
web_page = context.web_page_module.searchFolder(portal_type='Web Page',reference=web_page)[0] search_result = context.web_page_module.searchFolder(portal_type='Web Page', reference=web_page)
data = attribute_filter_re.findall(web_page.getTextContent()) if len(search_result) == 0:
context.log("Cannot find Web Page ref: \"" + web_page + "\"")
omitted += 1
if len(web_page) > len(longest_omitted_reference):
longest_omitted_reference = web_page
continue
processed += 1
data = attribute_filter_re.findall(search_result[0].getTextContent())
for attribute in data: for attribute in data:
a = re.sub(r'[{|}]', "", attribute[1]) a = re.sub(r'[{|}]', "", attribute[1])
a = re.sub(r'\[.*?\]', "", a) a = re.sub(r'\[.*?\]', "", a)
...@@ -51,4 +62,9 @@ translation_data_file.edit(text_content = content) ...@@ -51,4 +62,9 @@ translation_data_file.edit(text_content = content)
if batch_mode: if batch_mode:
return 'done' return 'done'
return context.Base_redirect('view', keep_items=dict(portal_status_message=Base_translateString("Translation Data Create")))
message = "Found {:d} words for translation in {:d} files from your appcache manifest.".format(len(translate_word), processed)
if omitted > 0:
message += "\n Skipped {:d} files with invalid reference (e.g. \"{}\")".format(omitted, longest_omitted_reference)
return context.Base_redirect('view', keep_items=dict(portal_status_message=Base_translateString(message)))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment