Commit e14ba9b1 authored by Yusei Tahara's avatar Yusei Tahara Committed by Romain Courteaud

[erp5_web_renderjs_ui] Replace Base_getListFileFromAppcache with Base_getTranslationSourceFileList.

Collect a list of files from service worker code.
parent 1d864fbf
......@@ -10,7 +10,7 @@ attribute_filter_re = re.compile(r"""(data-i18n)=["']?((?:.(?!["']?\s+(?:\S+)=|[
translate_word = []
for web_page in portal.web_page_module.searchFolder(portal_type='Web Page',
reference=context.Base_getListFileFromAppcache(only_html=1)):
reference=context.Base_getTranslationSourceFileList(only_html=1)):
data = attribute_filter_re.findall(web_page.getTextContent())
for attribute in data:
a = re.sub(r'[{|}]', "", attribute[1])
......
import re
text_content = context.portal_catalog.getResultValue(reference='gadget_erp5_serviceworker.js', portal_type='Web Script', validation_state=('published_alive', 'published')).getTextContent()
filename_pattern = re.compile("'(?P<filename>[a-zA-Z0-9-_\.\?=]*)'")
filename_list = []
start = False
for line in text_content.split('\n'):
if start is False and 'REQUIRED_FILES' in line:
start = True
continue
if not line:
continue
if start:
if ']' in line:
break
matched = filename_pattern.search(line)
if matched is not None:
filename = matched.groupdict().get('filename')
if filename:
filename_list.append(filename)
file_list = []
translation_data_file = []
for filename in filename_list:
if filename.endswith('.html'):
file_list.append(filename)
continue
if filename.endswith('.js') and not only_html:
if filename.endswith('translation_data.js'):
translation_data_file = [filename]
continue
file_list.append(filename)
return translation_data_file + file_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>only_html=0</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getTranslationSourceFileList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -54,6 +54,10 @@
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>first_item</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
......@@ -64,6 +68,10 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -107,7 +115,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: [ (x,x) for x in here.Base_getListFileFromAppcache()]</string> </value>
<value> <string>python: [ (x,x) for x in here.Base_getTranslationSourceFileList()]</string> </value>
</item>
</dictionary>
</pickle>
......
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