[Checkins] SVN: z3c.pt/trunk/ Added more tests for i18n attributes handling.

Hanno Schlichting plone at hannosch.info
Sat Jun 14 05:56:59 EDT 2008


Log message for revision 87389:
  Added more tests for i18n attributes handling.
  

Changed:
  U   z3c.pt/trunk/docs/HISTORY.txt
  U   z3c.pt/trunk/src/z3c/pt/i18n.txt

-=-
Modified: z3c.pt/trunk/docs/HISTORY.txt
===================================================================
--- z3c.pt/trunk/docs/HISTORY.txt	2008-06-14 09:44:21 UTC (rev 87388)
+++ z3c.pt/trunk/docs/HISTORY.txt	2008-06-14 09:56:59 UTC (rev 87389)
@@ -4,6 +4,8 @@
 Version 0.8.x
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+- Added more tests for i18n attributes handling.
+
 - Don't generate empty mappings for expressions with a trailing semicolon.
 
 - Fixed undefined name 'static' error in i18n attributes handling and added

Modified: z3c.pt/trunk/src/z3c/pt/i18n.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/i18n.txt	2008-06-14 09:44:21 UTC (rev 87388)
+++ z3c.pt/trunk/src/z3c/pt/i18n.txt	2008-06-14 09:56:59 UTC (rev 87389)
@@ -173,3 +173,96 @@
       Default
     </span>
   </div>
+
+Use an explicit msgid with a trailing semicolon.
+
+  >>> body = """\
+  ... <div xmlns="http://www.w3.org/1999/xhtml"
+  ...      xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+  ...   <span i18n:domain="test" title="Simple Title"
+  ...         i18n:attributes="title title_simple;">
+  ...     Default
+  ...   </span>
+  ... </div>"""
+
+Not passing a language:
+
+  >>> template = PageTemplate(body)
+  >>> print template.render()
+  <div>
+    <span title="Simple Title">
+      Default
+    </span>
+  </div>
+
+Passing German:
+
+  >>> print template.render(target_language='de')
+  <div>
+    <span title="Mock translation of 'title_simple'.">
+      Default
+    </span>
+  </div>
+
+Use multiple attributes on the same tag.
+
+  >>> body = """\
+  ... <div xmlns="http://www.w3.org/1999/xhtml"
+  ...      xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+  ...   <span i18n:domain="test" title="Simple Title"
+  ...         longdesc="A not so short description."
+  ...         i18n:attributes="title title_simple; longdesc desc_short">
+  ...     Default
+  ...   </span>
+  ... </div>"""
+
+Not passing a language:
+
+  >>> template = PageTemplate(body)
+  >>> print template.render()
+  <div>
+    <span longdesc="A not so short description." title="Simple Title">
+      Default
+    </span>
+  </div>
+
+Passing German:
+
+  >>> print template.render(target_language='de')
+  <div>
+    <span longdesc="Mock translation of 'desc_short'."
+          title="Mock translation of 'title_simple'.">
+      Default
+    </span>
+  </div>
+
+Translation of tag content and tag attributes
+---------------------------------------------
+
+A simple example to start with.
+  
+  >>> body = """\
+  ... <div xmlns="http://www.w3.org/1999/xhtml"
+  ...      xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+  ...   <span i18n:domain="test" i18n:translate="tid"
+  ...         title="Title" i18n:attributes="title aid">
+  ...     Default
+  ...   </span>
+  ... </div>"""
+
+Not passing a language:
+
+  >>> template = PageTemplate(body)
+  >>> print template.render()
+  <div>
+    <span title="Title">
+      Default
+    </span>
+  </div>
+
+Passing German:
+
+  >>> print template.render(target_language='de')
+  <div>
+    <span title="Mock translation of 'aid'.">Mock translation of 'tid'.</span>
+  </div>



More information about the Checkins mailing list