[Erp5-report] r23197 - in /erp5/trunk/bt5/erp5_forge: ExtensionTemplateItem/ SkinTemplateIt...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Aug 27 14:56:23 CEST 2008


Author: yusei
Date: Wed Aug 27 14:56:07 2008
New Revision: 23197

URL: http://svn.erp5.org?rev=23197&view=rev
Log:
2008-08-27 yusei
* Improve pot file export.

Added:
    erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_findMessageListFromPythonInProduct.xml
Modified:
    erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/Glossary.py
    erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py
    erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.xml
    erp5/trunk/bt5/erp5_forge/bt/change_log
    erp5/trunk/bt5/erp5_forge/bt/revision

Modified: erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/Glossary.py
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/Glossary.py?rev=23197&r1=23196&r2=23197&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/Glossary.py (original)
+++ erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/Glossary.py Wed Aug 27 14:56:07 2008
@@ -11,7 +11,7 @@
 
 
 def getActionTitleListFromAllActionProvider(portal):
-  result = {}
+  result = []
   provider_list = []
   for provider_id in portal.portal_actions.listActionProviders():
     if provider_id in ('portal_types', 'portal_workflow'):
@@ -24,13 +24,16 @@
   for typeinfo in portal.portal_types.objectValues():
     provider_list.append(typeinfo)
 
-  for action in provider.listActions():
-      result[action.title] = None
-  return result.keys()
+  for provider in provider_list:
+    for action in provider.listActions():
+        result.append((action.title, provider.getId()))
+  return result
 
 
 from StringIO import StringIO
 from TAL.HTMLTALParser import HTMLTALParser
+from TAL.TALParser import TALParser
+from TAL.TALGenerator import TALGenerator
 def findStaticTranslationText(page_template):
   def iterate(node, target_name, function):
     if type(node) is list:
@@ -56,7 +59,12 @@
     if interpreter._i18n_message_id_dict is not None:
       text_dict.update(interpreter._i18n_message_id_dict)
 
-  parser = HTMLTALParser()
+  if page_template.html():
+    generator = TALGenerator(xml=0)
+    parser = HTMLTALParser(generator)
+  else:
+    generator = TALGenerator(xml=1)
+    parser = TALParser(generator)
   parser.parseString(page_template._text)
   iterate(parser.gen.program, 'insertTranslation', addText)
   return text_dict.keys()
@@ -92,4 +100,3 @@
     self.guard = guard
   else:
     raise ValueError, "not a TransitionDefinition"
-

Modified: erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py?rev=23197&r1=23196&r2=23197&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py (original)
+++ erp5/trunk/bt5/erp5_forge/ExtensionTemplateItem/PythonScriptParserUtility.py Wed Aug 27 14:56:07 2008
@@ -21,6 +21,8 @@
         value = concatenate_add_const_value(arg)
       if value is not None:
         self.result.append(value)
+    for child_node in node.args:
+      self.preorder(child_node, self)
 
 
 def concatenate_add_const_value(node):
@@ -47,3 +49,34 @@
   visitor = Visitor(func_name)
   compiler.walk(ast, visitor)
   return visitor.result
+
+
+#
+# Collect translation message from products
+#
+import os.path
+import Products.ERP5
+def findMessageListFromPythonInProduct(function_name_list):
+  product_dir = os.path.dirname(Products.ERP5.__path__[0])
+  erp5_product_list = ('CMFActivity', 'CMFCategory',
+                       'ERP5', 'ERP5Banking', 'ERP5Catalog', 'ERP5Configurator',
+                       'ERP5Form', 'ERP5OOo', 'ERP5Security', 'ERP5Subversion',
+                       'ERP5SyncML', 'ERP5Type', 'ERP5Wizard', 'ERP5Workflow',
+                       'HBTreeFolder2', 'MailTemplates', 'TimerService',
+                       'ZMySQLDA', 'ZMySQLDDA', 'ZSQLCatalog',
+                       )
+  result = []
+  def findStaticMessage(file_path):
+    source = open(file_path).read()
+    for func_name in function_name_list:
+      call_func_name = '%s(' % func_name
+      if call_func_name in source:
+        for m in getFunctionFirstArgumentValue(func_name, source):
+          result.append((m, file_path))
+  def visit(arg, dirname, filename_list):
+    for filename in filename_list:
+      if filename.endswith('.py'):
+        findStaticMessage(os.path.join(dirname, filename))
+  for product_name in erp5_product_list:
+    os.path.walk(os.path.join(product_dir, product_name), visit, None)
+  return result

Added: erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_findMessageListFromPythonInProduct.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_findMessageListFromPythonInProduct.xml?rev=23197&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_findMessageListFromPythonInProduct.xml (added)
+++ erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/Base_findMessageListFromPythonInProduct.xml Wed Aug 27 14:56:07 2008
@@ -1,0 +1,37 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <tuple>
+        <global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
+        <tuple/>
+      </tuple>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>__ac_local_roles__</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_function</string> </key>
+            <value> <string>findMessageListFromPythonInProduct</string> </value>
+        </item>
+        <item>
+            <key> <string>_module</string> </key>
+            <value> <string>PythonScriptParserUtility</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>Base_findMessageListFromPythonInProduct</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.xml?rev=23197&r1=23196&r2=23197&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.xml (original)
+++ erp5/trunk/bt5/erp5_forge/SkinTemplateItem/portal_skins/erp5_toolbox/ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot.xml Wed Aug 27 14:56:07 2008
@@ -92,12 +92,19 @@
       form_list.append(i)\n
     elif i.meta_type==\'ListBox\' or i.id==\'listbox\':\n
       listbox_list.append(i)\n
-    elif i.meta_type==\'Page Template\' and i.content_type.startswith(\'text/html\'):\n
+    elif i.meta_type in (\'Page Template\',\n
+                         \'ERP5 PDF Template\',\n
+                         \'ERP5 OOo Template\'):\n
       page_template_list.append(i)\n
     if i.isPrincipiaFolderish:\n
       iterate(i)\n
 iterate(context.portal_skins)\n
 \n
+# Collect python script from workflow objects.\n
+for workflow in context.portal_workflow.objectValues():\n
+  for i in workflow.scripts.objectValues():\n
+    if i.meta_type==\'Script (Python)\':\n
+      python_script_list.append(i)\n
 \n
 #\n
 # Python Script\n
@@ -116,6 +123,11 @@
       for m in Base_getFunctionFirstArgumentValue(func_name, source):\n
         add_message(m, portal_url.getRelativeContentURL(i))\n
 \n
+#\n
+# Python in Products\n
+#\n
+for message, path in context.Base_findMessageListFromPythonInProduct(FUNC_NAME_LIST):\n
+  add_message(message, path)\n
 \n
 #\n
 # ERP5 Form title\n
@@ -129,9 +141,9 @@
 #\n
 for i in listbox_list:\n
   add_message(i.title(), portal_url.getRelativeContentURL(i))\n
-  for value, label in i.get_value(\'columns\'):\n
+  for value, label in i.get_value(\'columns\') or ():\n
     add_message(label, portal_url.getRelativeContentURL(i))\n
-  for value, label in i.get_value(\'all_columns\'):\n
+  for value, label in i.get_value(\'all_columns\') or ():\n
     add_message(label, portal_url.getRelativeContentURL(i))\n
 \n
 #\n
@@ -146,6 +158,7 @@
 # Workflow\n
 #\n
 for i in context.portal_workflow.objectValues():\n
+  add_message(i.title_or_id(), portal_url.getRelativeContentURL(i))\n
   if not i.states:\n
     continue\n
   for s in i.states.values():\n
@@ -157,6 +170,8 @@
   for t in i.transitions.values():\n
     if t.actbox_name:\n
       add_message(t.actbox_name, portal_url.getRelativeContentURL(t))\n
+  for worklist in i.worklists.objectValues():\n
+    add_message(worklist.actbox_name, portal_url.getRelativeContentURL(worklist))\n
 \n
 \n
 #\n
@@ -169,8 +184,8 @@
 #\n
 # Action\n
 #\n
-for action_title in context.Base_getActionTitleListFromAllActionProvider(context.getPortalObject()):\n
-  add_message(action_title, \'action\')\n
+for action_title, action_provider_id in context.Base_getActionTitleListFromAllActionProvider(context.getPortalObject()):\n
+  add_message(action_title, action_provider_id)\n
 \n
 \n
 #\n
@@ -262,24 +277,28 @@
                             <string>listbox_list</string>
                             <string>page_template_list</string>
                             <string>iterate</string>
+                            <string>_getiter_</string>
+                            <string>workflow</string>
+                            <string>i</string>
                             <string>FUNC_NAME_LIST</string>
                             <string>Base_getFunctionFirstArgumentValue</string>
-                            <string>_getiter_</string>
-                            <string>i</string>
                             <string>source</string>
                             <string>func_name</string>
                             <string>call_func_name</string>
                             <string>m</string>
+                            <string>message</string>
+                            <string>path</string>
                             <string>value</string>
                             <string>label</string>
                             <string>Base_findStaticTranslationText</string>
                             <string>s</string>
                             <string>t</string>
+                            <string>worklist</string>
                             <string>action_title</string>
+                            <string>action_provider_id</string>
                             <string>format</string>
                             <string>MESSAGE_TEMPLATE</string>
                             <string>message_list</string>
-                            <string>message</string>
                             <string>_getitem_</string>
                             <string>comment_list</string>
                             <string>append</string>
@@ -305,6 +324,12 @@
             <value> <string>ERP5Site_getToBeTranslatedMessageListFromEntireSystemAsPot</string> </value>
         </item>
         <item>
+            <key> <string>uid</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
             <key> <string>warnings</string> </key>
             <value>
               <tuple/>

Modified: erp5/trunk/bt5/erp5_forge/bt/change_log
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/bt/change_log?rev=23197&r1=23196&r2=23197&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/bt/change_log (original)
+++ erp5/trunk/bt5/erp5_forge/bt/change_log Wed Aug 27 14:56:07 2008
@@ -1,3 +1,6 @@
+2008-08-27 yusei
+* Improve pot file export.
+
 2008-06-16 Nicolas
 Add external Method to see Security for arbitrary user
 

Modified: erp5/trunk/bt5/erp5_forge/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_forge/bt/revision?rev=23197&r1=23196&r2=23197&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_forge/bt/revision (original)
+++ erp5/trunk/bt5/erp5_forge/bt/revision Wed Aug 27 14:56:07 2008
@@ -1,1 +1,1 @@
-320
+321




More information about the Erp5-report mailing list