[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL/tests - test_htmltalparser.py:1.33

Barry Warsaw barry@wooz.org
Mon, 1 Jul 2002 11:59:13 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/TAL/tests
In directory cvs.zope.org:/tmp/cvs-serv5877/lib/python/Zope/TAL/tests

Modified Files:
	test_htmltalparser.py 
Log Message:
Merging tal-i18n-refactor-branch back into the Zope3 trunk.


=== Zope3/lib/python/Zope/TAL/tests/test_htmltalparser.py 1.32 => 1.33 ===
 
     def check_i18n_translate(self):
+        # input/test19.html
         self._run_check('''\
 <span i18n:translate="">Replace this</span>
 <span i18n:translate="msgid">This is a
@@ -547,6 +548,7 @@
   ])
 
     def check_i18n_name(self):
+        # input/test21.html
         self._run_check('''\
 <span i18n:translate="">
   <span tal:replace="str:Lomax" i18n:name="name" /> was born in
@@ -566,11 +568,11 @@
        {'i18n:name': 'name', 'tal:replace': 'str:Lomax'})),
      ('i18nVariable',
       ('name',
-       '$str:Lomax$',
        [('startEndTag',
          ('span',
           [('tal:replace', 'str:Lomax', 'tal'),
-           ('i18n:name', 'name', 'i18n')]))])),
+           ('i18n:name', 'name', 'i18n')]))],
+       '$str:Lomax$')),
      ('rawtextBeginScope',
       (' was born in\n  ',
        2,
@@ -579,11 +581,11 @@
        {'i18n:name': 'country', 'tal:replace': 'str:Antarctica'})),
      ('i18nVariable',
       ('country',
-       '$str:Antarctica$',
        [('startEndTag',
          ('span',
           [('tal:replace', 'str:Antarctica', 'tal'),
-           ('i18n:name', 'country', 'i18n')]))])),
+           ('i18n:name', 'country', 'i18n')]))],
+       '$str:Antarctica$')),
      ('endScope', ()),
      ('rawtextColumn', ('.\n', 0))])),
   ('endScope', ()),
@@ -591,6 +593,7 @@
   ])
 
     def check_i18n_name_implicit_value(self):
+        # input/test22.html
         self._run_check('''\
 <span i18n:translate="">
   <span i18n:name="name"><b>Jim</b></span> was born in
@@ -605,16 +608,12 @@
     [('rawtextBeginScope', ('\n  ', 2, (2, 2), 0, {'i18n:name': 'name'})),
      ('i18nVariable',
       ('name',
-       [('rawtextOffset', ('<b>Jim</b>', 10))],
-       [('startTag', ('span', [('i18n:name', 'name', 'i18n')])),
-        ('rawtextOffset', ('<b>Jim</b></span>', 17))])),
+       [('rawtextOffset', ('<b>Jim</b>', 10))], None)),
      ('rawtextBeginScope',
       (' was born in\n  ', 2, (3, 2), 1, {'i18n:name': 'country'})),
      ('i18nVariable',
       ('country',
-       [('rawtextOffset', ('the USA', 7))],
-       [('startTag', ('span', [('i18n:name', 'country', 'i18n')])),
-        ('rawtextOffset', ('the USA</span>', 14))])),
+       [('rawtextOffset', ('the USA', 7))], None)),
      ('endScope', ()),
      ('rawtextColumn', ('.\n', 0))])),
   ('endScope', ()),
@@ -683,6 +682,7 @@
             ])
 
     def check_i18n_data(self):
+        # input/test23.html
         self._run_check('''\
 <span i18n:data="here/currentTime"
       i18n:translate="timefmt">2:32 pm</span>
@@ -701,6 +701,7 @@
   ])
 
     def check_i18n_data_with_name(self):
+        # input/test29.html
         self._run_check('''\
 At the tone the time will be
 <span i18n:data="here/currentTime"
@@ -715,27 +716,21 @@
     {'i18n:data': 'here/currentTime',
      'i18n:name': 'time',
      'i18n:translate': 'timefmt'})),
-  ('i18nVariable',
-   ('time',
-    [('insertTranslation',
-      ('timefmt',
-       [('rawtextOffset', ('2:32 pm', 7))],
-       '$here/currentTime$'))],
+  ('insertTranslation',
+   ('timefmt',
     [('startTag',
       ('span',
        [('i18n:data', 'here/currentTime', 'i18n'),
         ('i18n:translate', 'timefmt', 'i18n'),
         ('i18n:name', 'time', 'i18n')])),
-     ('insertTranslation',
-      ('timefmt',
-       [('rawtextOffset', ('2:32 pm', 7))],
-       '$here/currentTime$')),
-     ('rawtextOffset', ('</span>', 7))])),
+     ('i18nVariable', ('time', [], None))],
+    '$here/currentTime$')),
   ('endScope', ()),
   ('rawtextColumn', ('... beep!\n', 0))
   ])
 
     def check_i18n_explicit_msgid_with_name(self):
+        # input/test26.html
         self._run_check('''\
 <span i18n:translate="jobnum">
     Job #<span tal:replace="context/@@object_name"
@@ -754,15 +749,101 @@
        {'i18n:name': 'jobnum', 'tal:replace': 'context/@@object_name'})),
      ('i18nVariable',
       ('jobnum',
-       '$context/@@object_name$',
        [('startTag',
          ('span',
           [('tal:replace', 'context/@@object_name', 'tal'),
            ('i18n:name', 'jobnum', 'i18n')])),
-        ('rawtextOffset', ('NN</span>', 9))])),
+        ('rawtextOffset', ('NN', 2)),
+        ('rawtextOffset', ('</span>', 7))],
+       '$context/@@object_name$')),
      ('endScope', ())])),
   ('endScope', ()),
   ('rawtextColumn', ('</span>\n', 0))
+  ])
+
+    def check_i18n_name_around_tal_content(self):
+        # input/test28.html
+        self._run_check('''\
+<p i18n:translate="verify">Your contact email address is recorded as
+    <span i18n:name="email">
+    <a href="mailto:user@example.com"
+       tal:content="request/submitter">user@host.com</a></span>
+</p>
+''', [
+  ('setPosition', (1, 0)),
+  ('beginScope', {'i18n:translate': 'verify'}),
+  ('startTag', ('p', [('i18n:translate', 'verify', 'i18n')])),
+  ('insertTranslation',
+   ('verify',
+    [('rawtextBeginScope',
+      ('Your contact email address is recorded as\n    ',
+       4,
+       (2, 4),
+       0,
+       {'i18n:name': 'email'})),
+     ('i18nVariable',
+      ('email',
+       [('rawtextBeginScope',
+         ('\n    ',
+          4,
+          (3, 4),
+          0,
+          {'href': 'mailto:user@example.com',
+           'tal:content': 'request/submitter'})),
+        ('startTag',
+         ('a',
+          [('href', 'href="mailto:user@example.com"'),
+           ('tal:content', 'request/submitter', 'tal')])),
+        ('insertText',
+         ('$request/submitter$',
+          [('rawtextOffset', ('user@host.com', 13))])),
+        ('endScope', ()),
+        ('rawtextOffset', ('</a>', 4))],
+       None)),
+     ('endScope', ()),
+     ('rawtextColumn', ('\n', 0))])),
+  ('endScope', ()),
+  ('rawtextColumn', ('</p>\n', 0))
+  ])
+
+    def check_i18n_name_with_tal_content(self):
+        # input/test27.html
+        self._run_check('''\
+<p i18n:translate="verify">Your contact email address is recorded as
+    <a href="mailto:user@example.com"
+       tal:content="request/submitter"
+       i18n:name="email">user@host.com</a>
+</p>
+''', [
+  ('setPosition', (1, 0)),
+  ('beginScope', {'i18n:translate': 'verify'}),
+  ('startTag', ('p', [('i18n:translate', 'verify', 'i18n')])),
+  ('insertTranslation',
+   ('verify',
+    [('rawtextBeginScope',
+      ('Your contact email address is recorded as\n    ',
+       4,
+       (2, 4),
+       0,
+       {'href': 'mailto:user@example.com',
+        'i18n:name': 'email',
+        'tal:content': 'request/submitter'})),
+     ('i18nVariable',
+      ('email',
+       [('startTag',
+         ('a',
+          [('href', 'href="mailto:user@example.com"'),
+           ('tal:content', 'request/submitter', 'tal'),
+           ('i18n:name', 'email', 'i18n')])),
+        ('insertText',
+         ('$request/submitter$',
+          [('rawtextOffset', ('user@host.com', 13))])),
+        ('rawtextOffset', ('</a>', 4))],
+       None)),
+     ('endScope', ()),
+     ('rawtextColumn', ('\n', 0))])),
+  ('endScope', ()),
+  ('rawtextColumn', ('</p>\n', 0))
   ])