[Checkins] SVN: z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/ fixed translation in demo and added test

Bernd Dorn bernd.dorn at fhv.at
Mon Jul 10 06:41:03 EDT 2006


Log message for revision 69069:
  fixed translation in demo and added test

Changed:
  U   z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/README.txt
  U   z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/configure.zcml
  U   z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/countries.py

-=-
Modified: z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/README.txt
===================================================================
--- z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/README.txt	2006-07-10 10:25:29 UTC (rev 69068)
+++ z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/README.txt	2006-07-10 10:41:02 UTC (rev 69069)
@@ -37,7 +37,7 @@
     >>> browser.open('http://localhost/mydemo/@@edit.html/++widget++country/suggestions')
     >>> print browser.contents
 
-    >>> browser.open('http://localhost/mydemo/@@edit.html/++widget++country/suggestions?value=a')
+    >>> browser.open('http://localhost/++lang++en/mydemo/@@edit.html/++widget++country/suggestions?value=a')
     >>> print browser.contents
     <BLANKLINE>
      <ul>
@@ -59,3 +59,29 @@
      </ul>
     <BLANKLINE>
     <BLANKLINE>
+
+Suggestions are translated.
+
+    >>> browser.open('http://localhost/++lang++de/mydemo/@@edit.html/++widget++country/suggestions?value=a')
+    >>> print browser.contents
+    <BLANKLINE>
+     <ul>
+      <li>Amerikanische Jungferninseln</li>
+      <li>Amerikanisch-Ozeanien</li>
+      <li>Algerien</li>
+      <li>Andorra</li>
+      <li>Antigua und Barbuda</li>
+      <li>Afghanistan</li>
+      <li>Anguilla</li>
+      <li>Armenien</li>
+      <li>Albanien</li>
+      <li>Angola</li>
+      <li>Antarktis</li>
+      <li>Amerikanisch-Samoa</li>
+      <li>Argentinien</li>
+      <li>Australien</li>
+      <li>Aruba</li>
+      <li>Aserbaidschan</li>
+     </ul>
+    <BLANKLINE>
+    <BLANKLINE>

Modified: z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/configure.zcml
===================================================================
--- z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/configure.zcml	2006-07-10 10:25:29 UTC (rev 69068)
+++ z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/configure.zcml	2006-07-10 10:41:02 UTC (rev 69069)
@@ -4,6 +4,11 @@
            i18n_domain="zope">
 
  <utility
+  component=".countries.territoryTranslationDomain"
+  provides="zope.i18n.ITranslationDomain"
+  name="autocomplete.demo.countries"/>
+ 
+ <utility
   provides="zope.schema.interfaces.IVocabularyFactory"
   component=".countries.territoryVocabularyFactory"
   name="autocomplete.demo.countries"

Modified: z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/countries.py
===================================================================
--- z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/countries.py	2006-07-10 10:25:29 UTC (rev 69068)
+++ z3c.widget/sandbox/src/z3c/widget/autocomplete/demo/countries.py	2006-07-10 10:41:02 UTC (rev 69069)
@@ -4,8 +4,21 @@
 from zope.i18nmessageid.message import MessageFactory
 from zope.schema.vocabulary import SimpleVocabulary,SimpleTerm
 from zope.i18n import interpolate
+from zope.component import getUtility
+import glob
+import os
 
+# the whole module is copied from z3c.i18n.iso
 
+# get the locales list
+# XXX maybe we should load variants too?
+LANGS = []
+for name in glob.glob(os.path.join(LOCALEDIR,'??.xml')):
+    LANGS.append(os.path.basename(name)[:2])
+
+
+
+
 class DisplayNameTranslationDomain(object):
 
     """base class for displayname based translation domains"""
@@ -41,7 +54,7 @@
     >>> d.translate('DE',target_language='en')
     u'Germany'
     """
-    domain='z3c.i18n.iso.territories'
+    domain='autocomplete.demo.countries'
     displayNameAttr = 'territories'
 
 territoryTranslationDomain = TerritoryTranslationDomain()



More information about the Checkins mailing list