[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/rotterdam/ All messages for XMLTree are now translatable

Dmitry Vasiliev dima at hlabs.spb.ru
Thu May 5 03:59:55 EDT 2005


Log message for revision 30242:
  All messages for XMLTree are now translatable
  

Changed:
  U   Zope3/trunk/src/zope/app/rotterdam/tests/output/test1.xml
  U   Zope3/trunk/src/zope/app/rotterdam/tests/output/test5.xml
  U   Zope3/trunk/src/zope/app/rotterdam/tests/output/test6.xml
  U   Zope3/trunk/src/zope/app/rotterdam/tests/output/test7.xml
  U   Zope3/trunk/src/zope/app/rotterdam/tests/output/test8.xml
  U   Zope3/trunk/src/zope/app/rotterdam/xmlobject.py
  U   Zope3/trunk/src/zope/app/rotterdam/xmltree.js

-=-
Modified: Zope3/trunk/src/zope/app/rotterdam/tests/output/test1.xml
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/tests/output/test1.xml	2005-05-05 06:20:57 UTC (rev 30241)
+++ Zope3/trunk/src/zope/app/rotterdam/tests/output/test1.xml	2005-05-05 07:59:55 UTC (rev 30242)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="[top]" baseURL="http://127.0.0.1/" length="3" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""></collection><collection name="folder2" length="1" icon_url=""/><collection name="папка3" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>
+<?xml version="1.0" ?><children title_tpl="Contains $${num} item(s)" loading_msg="Loading..."><collection name="[top]" baseURL="http://127.0.0.1/" length="3" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""></collection><collection name="folder2" length="1" icon_url=""/><collection name="папка3" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>

Modified: Zope3/trunk/src/zope/app/rotterdam/tests/output/test5.xml
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/tests/output/test5.xml	2005-05-05 06:20:57 UTC (rev 30241)
+++ Zope3/trunk/src/zope/app/rotterdam/tests/output/test5.xml	2005-05-05 07:59:55 UTC (rev 30242)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="[top]" baseURL="http://127.0.0.1/" length="3" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""><collection name="folder1_1" length="2" icon_url=""><collection name="folder1_1_1" length="1" icon_url=""></collection><collection name="folder1_1_2" length="0" icon_url=""/><item name="++etc++site" icon_url="" /></collection><collection name="folder1_2" length="1" icon_url=""/><item name="++etc++site" icon_url="" /></collection><collection name="folder2" length="1" icon_url=""/><collection name="папка3" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>
+<?xml version="1.0" ?><children title_tpl="Contains $${num} item(s)" loading_msg="Loading..."><collection name="[top]" baseURL="http://127.0.0.1/" length="3" icon_url="" isroot=""><collection name="folder1" length="2" icon_url=""><collection name="folder1_1" length="2" icon_url=""><collection name="folder1_1_1" length="1" icon_url=""></collection><collection name="folder1_1_2" length="0" icon_url=""/><item name="++etc++site" icon_url="" /></collection><collection name="folder1_2" length="1" icon_url=""/><item name="++etc++site" icon_url="" /></collection><collection name="folder2" length="1" icon_url=""/><collection name="папка3" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>

Modified: Zope3/trunk/src/zope/app/rotterdam/tests/output/test6.xml
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/tests/output/test6.xml	2005-05-05 06:20:57 UTC (rev 30241)
+++ Zope3/trunk/src/zope/app/rotterdam/tests/output/test6.xml	2005-05-05 07:59:55 UTC (rev 30242)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="[subsite]" baseURL="http://127.0.0.1/" length="2" icon_url="" isroot=""></collection></children>
+<?xml version="1.0" ?><children title_tpl="Contains $${num} item(s)" loading_msg="Loading..."><collection name="[subsite]" baseURL="http://127.0.0.1/" length="2" icon_url="" isroot=""></collection></children>

Modified: Zope3/trunk/src/zope/app/rotterdam/tests/output/test7.xml
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/tests/output/test7.xml	2005-05-05 06:20:57 UTC (rev 30241)
+++ Zope3/trunk/src/zope/app/rotterdam/tests/output/test7.xml	2005-05-05 07:59:55 UTC (rev 30242)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="[subsite]" baseURL="http://127.0.0.1/" length="2" icon_url="" isroot=""><collection name="subfolder1" length="0" icon_url=""></collection><collection name="subfolder2" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>
\ No newline at end of file
+<?xml version="1.0" ?><children title_tpl="Contains $${num} item(s)" loading_msg="Loading..."><collection name="[subsite]" baseURL="http://127.0.0.1/" length="2" icon_url="" isroot=""><collection name="subfolder1" length="0" icon_url=""></collection><collection name="subfolder2" length="1" icon_url=""/><collection name="++etc++site" length="1" icon_url=""/></collection></children>

Modified: Zope3/trunk/src/zope/app/rotterdam/tests/output/test8.xml
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/tests/output/test8.xml	2005-05-05 06:20:57 UTC (rev 30241)
+++ Zope3/trunk/src/zope/app/rotterdam/tests/output/test8.xml	2005-05-05 07:59:55 UTC (rev 30242)
@@ -1 +1 @@
-<?xml version="1.0" ?><children><collection name="[subsite]" baseURL="http://127.0.0.1/" length="2" icon_url="" isroot=""><collection name="subfolder1" length="0" icon_url=""/><collection name="subfolder2" length="1" icon_url=""><collection name="subfolder2_1" length="0" icon_url=""></collection><item name="++etc++site" icon_url="" /></collection><collection name="++etc++site" length="1" icon_url=""/></collection></children>
\ No newline at end of file
+<?xml version="1.0" ?><children title_tpl="Contains $${num} item(s)" loading_msg="Loading..."><collection name="[subsite]" baseURL="http://127.0.0.1/" length="2" icon_url="" isroot=""><collection name="subfolder1" length="0" icon_url=""/><collection name="subfolder2" length="1" icon_url=""><collection name="subfolder2_1" length="0" icon_url=""></collection><item name="++etc++site" icon_url="" /></collection><collection name="++etc++site" length="1" icon_url=""/></collection></children>

Modified: Zope3/trunk/src/zope/app/rotterdam/xmlobject.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/xmlobject.py	2005-05-05 06:20:57 UTC (rev 30241)
+++ Zope3/trunk/src/zope/app/rotterdam/xmlobject.py	2005-05-05 07:59:55 UTC (rev 30242)
@@ -31,6 +31,9 @@
 from zope.app.i18n import ZopeMessageIDFactory as _
 
 
+titleTemplate = _('Contains $${num} item(s)')
+loadingMsg = _('Loading...')
+
 def setNoCacheHeaders(response):
     """Ensure that the tree isn't cached"""
     response.setHeader('Pragma', 'no-cache')
@@ -203,14 +206,21 @@
 
         # do not forget root folder
         iconUrl = self.getIconUrl(oldItem)
-        result = (xmlEscapeWithCData(
+        result = xmlEscapeWithCData(
                   u'<collection name=%s baseURL=%s length=%s '
                   u'icon_url=%s isroot="">%s</collection>',
-                  rootName, baseURL, len(oldItem), iconUrl, result))
+                  rootName, baseURL, len(oldItem), iconUrl, result)
 
         self.request.response.setHeader('Content-Type', 'text/xml')
         setNoCacheHeaders(self.request.response)
-        return u'<?xml version="1.0" ?><children> %s </children>' % result
+        title = translate(titleTemplate,
+                          context=self.request, default=titleTemplate)
+        loading = translate(loadingMsg,
+                          context=self.request, default=loadingMsg)
+        return xmlEscapeWithCData(
+                u'<?xml version="1.0" ?>'
+                u'<children title_tpl=%s loading_msg=%s>%s</children>',
+                title, loading, result)
 
 class XmlObjectView(BrowserView):
     """Provide a xml interface for dynamic navigation tree in UI"""

Modified: Zope3/trunk/src/zope/app/rotterdam/xmltree.js
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/xmltree.js	2005-05-05 06:20:57 UTC (rev 30241)
+++ Zope3/trunk/src/zope/app/rotterdam/xmltree.js	2005-05-05 07:59:55 UTC (rev 30242)
@@ -7,6 +7,7 @@
 var XML_CHILDREN_VIEW = '@@children.xml';
 var SINGLE_BRANCH_TREE_VIEW = '@@singleBranchTree.xml';
 var CONTENT_VIEW = '@@SelectedManagementView.html';
+var NUM_TEMPLATE = '$${num}';
 
 
 var LG_DEBUG = 6;
@@ -17,6 +18,8 @@
 
 
 // globals
+var loadingMsg = 'Loading...';
+var titleTemplate = 'Contains ' + NUM_TEMPLATE + ' item(s)';
 var baseurl;
 var navigationTree;
 var docNavTree;
@@ -47,12 +50,12 @@
 }
 
 navigationTreeNode.prototype.collapse = function() {
- 	this.isCollapsed = 1;
+        this.isCollapsed = 1;
         this.changeExpandIcon("pl.gif");
 }
 
 navigationTreeNode.prototype.expand = function() {
- 	this.isCollapsed = 0;
+        this.isCollapsed = 0;
         this.changeExpandIcon("mi.gif");
 }
 
@@ -115,14 +118,14 @@
 navigationTreeNode.prototype.refreshExpansion = function() {
 with (this) {
         if (isCollapsed) {
-	 	expand();
+                expand();
                 showChildren();
-   		}
+        }
         else {
                 collapse();
                 hideChildren();
-   		}
         }
+        }
 }
 
 
@@ -130,19 +133,19 @@
 with (this) {
         prettydump('hideChildren', LG_TRACE);
         var num = childNodes.length;
-	for (var i = num - 1; i >=0; i--) {
-	        childNodes[i].domNode.style.display = 'none';
-        	}
+        for (var i = num - 1; i >=0; i--) {
+                childNodes[i].domNode.style.display = 'none';
         }
+        }
 }
 
 navigationTreeNode.prototype.showChildren = function() {
 with (this) {
         prettydump('showChildren', LG_TRACE);
         var num = childNodes.length;
-	for (var i = num - 1; i >=0; i--) {
-	        childNodes[i].domNode.style.display = 'block';
-        	}
+        for (var i = num - 1; i >=0; i--) {
+                childNodes[i].domNode.style.display = 'block';
+            }
         }
 }
 
@@ -151,16 +154,16 @@
         // Put the string "s" in a box on the screen as an log message
         if (locallog <= loglevel) {
                 var logger = document.getElementById('logger');
-  	        var msg = document.createElement('code');
-	        var br1 = document.createElement('br');
-  	        var br2 = document.createElement('br');
-  	        var msg_text = document.createTextNode(s);
-  	        msg.appendChild(msg_text);
-          	logger.insertBefore(br1, logger.firstChild);
-  	        logger.insertBefore(br2, logger.firstChild);
-          	logger.insertBefore(msg, logger.firstChild);
-	        }
+                var msg = document.createElement('code');
+                var br1 = document.createElement('br');
+                var br2 = document.createElement('br');
+                var msg_text = document.createTextNode(s);
+                msg.appendChild(msg_text);
+                logger.insertBefore(br1, logger.firstChild);
+                logger.insertBefore(br2, logger.firstChild);
+                logger.insertBefore(msg, logger.firstChild);
         }
+        }
 
 
 function debug(s) {
@@ -172,16 +175,16 @@
 
 // DOM utilities
 function getTreeEventTarget(e) {
-	var elem;
+        var elem;
         if(e.target) {
                 // Mozilla uses this
-       		if (e.target.nodeType == TEXT_NODE) {
+                if (e.target.nodeType == TEXT_NODE) {
                         elem=e.target.parentNode;
-		        }
-		else {
-		        elem=e.target;
-			}
+        }
+        else {
+                elem=e.target;
                 }
+                }
         else {
                 // IE uses this
                 elem=e.srcElement;
@@ -190,21 +193,21 @@
         }
 
 function isCollection(elem) {
-	return (checkTagName(elem, COLLECTION));
-	}
+        return (checkTagName(elem, COLLECTION));
+        }
 
 
 function isIcon(elem) {
-	return (checkTagName(elem, ICON));
-	}
+        return (checkTagName(elem, ICON));
+        }
 
 function isExpand(elem) {
-	return (checkTagName(elem, EXPAND));
-	}
+        return (checkTagName(elem, EXPAND));
+        }
 
 function checkTagName(elem, tagName) {
-	return (elem.tagName.toUpperCase() == tagName);
-	}
+        return (elem.tagName.toUpperCase() == tagName);
+        }
 
 function getCollectionChildNodes(xmlDomElem) {
         // get collection element nodes among childNodes of elem
@@ -299,16 +302,16 @@
 
 
                 xmlHttp.onreadystatechange = function () {
-        		if (xmlHttp.readyState == 4) {
+                    if (xmlHttp.readyState == 4) {
                                 prettydump('Response XML ' + xmlHttp.responseText, LG_INFO);
-			        parseXML(xmlHttp.responseXML, node);
-		                }
-	                };
+                                parseXML(xmlHttp.responseXML, node);
+                            }
+                            };
 
                 // call in new thread to allow ui to update
-	        window.setTimeout(function () {
-		        xmlHttp.send(null);
-	                }, 10);
+                window.setTimeout(function () {
+                        xmlHttp.send(null);
+                        }, 10);
                 }
         else {
                 }
@@ -318,7 +321,7 @@
         baseurl = rooturl;  // Global baseurl
         docNavTree = document.getElementById('navtreecontents');
 
-	var url = thisbaseurl + SINGLE_BRANCH_TREE_VIEW;
+        var url = thisbaseurl + SINGLE_BRANCH_TREE_VIEW;
         loadtreexml(url, null);
         }
 
@@ -338,6 +341,8 @@
                 if (node == null) {
                         //[top] node
                         removeChildren(docNavTree);
+                        titleTemplate = data.getAttribute('title_tpl');
+                        loadingMsg = data.getAttribute('loading_msg');
                         addNavigationTreeNodes(data, null, 1);
 //                        docNavTree.appendChild(navigationTree.domNode);
                         }
@@ -385,7 +390,8 @@
         var titleTextNode = document.createTextNode(title);
 
         linkElem.appendChild(titleTextNode);
-        linkElem.setAttribute('title', 'Contains ' + length + ' item(s)');
+        var titleText = titleTemplate.split(NUM_TEMPLATE).join(length);
+        linkElem.setAttribute('title', titleText);
         linkElem.setAttribute('href', targetUrl);
 
         iconElem.appendChild(linkElem);
@@ -395,8 +401,7 @@
 
 function createLoadingNode() {
         var loadingElem = document.createElement('loading');
-        //XXX should not hardcode loading string
-        var titleTextNode = document.createTextNode('Loading...');
+        var titleTextNode = document.createTextNode(loadingMsg);
 
         loadingElem.appendChild(titleTextNode);
 
@@ -458,4 +463,3 @@
                 }
         return navTreeNode;
         }
-



More information about the Zope3-Checkins mailing list