Exemplo n.º 1
0
Arquivo: i18n.py Projeto: alon/polinax
 def test_extraction_with_nonstring_arg(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       ${dgettext(curdomain, 'Foobar')}
     </html>""")
     results = list(extract(buf, ['dgettext'], [], {}))
     self.assertEqual([
         (2, 'dgettext', (None, u'Foobar'), []),
     ], results)
Exemplo n.º 2
0
 def test_extraction_with_nonstring_arg(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       ${dgettext(curdomain, 'Foobar')}
     </html>""")
     results = list(extract(buf, ['dgettext'], [], {}))
     self.assertEqual([
         (2, 'dgettext', (None, u'Foobar'), []),
     ], results)
Exemplo n.º 3
0
Arquivo: i18n.py Projeto: alon/polinax
 def test_extraction_with_keyword_arg(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       ${gettext('Foobar', foo='bar')}
     </html>""")
     results = list(extract(buf, ['gettext'], [], {}))
     self.assertEqual([
         (2, 'gettext', (u'Foobar'), []),
     ], results)
Exemplo n.º 4
0
 def test_extraction_with_keyword_arg(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       ${gettext('Foobar', foo='bar')}
     </html>""")
     results = list(extract(buf, ['gettext'], [], {}))
     self.assertEqual([
         (2, 'gettext', (u'Foobar'), []),
     ], results)
Exemplo n.º 5
0
Arquivo: i18n.py Projeto: alon/polinax
 def test_extraction_inside_ignored_tags_with_directives(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <script type="text/javascript">
         <py:if test="foobar">
           alert("This shouldn't be extracted");
         </py:if>
       </script>
     </html>""")
     self.assertEqual([], list(extract(buf, ['_'], [], {})))
Exemplo n.º 6
0
 def test_extraction_inside_ignored_tags_with_directives(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <script type="text/javascript">
         <py:if test="foobar">
           alert("This shouldn't be extracted");
         </py:if>
       </script>
     </html>""")
     self.assertEqual([], list(extract(buf, ['_'], [], {})))
Exemplo n.º 7
0
 def test_extraction_without_text(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <p title="Bar">Foo</p>
       ${ngettext("Singular", "Plural", num)}
     </html>""")
     results = list(
         extract(buf, ['_', 'ngettext'], [], {'extract_text': 'no'}))
     self.assertEqual([
         (3, 'ngettext', (u'Singular', u'Plural'), []),
     ], results)
Exemplo n.º 8
0
Arquivo: i18n.py Projeto: alon/polinax
 def test_extraction_without_text(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <p title="Bar">Foo</p>
       ${ngettext("Singular", "Plural", num)}
     </html>""")
     results = list(extract(buf, ['_', 'ngettext'], [], {
         'extract_text': 'no'
     }))
     self.assertEqual([
         (3, 'ngettext', (u'Singular', u'Plural', None), []),
     ], results)
Exemplo n.º 9
0
Arquivo: i18n.py Projeto: alon/polinax
 def test_extraction_inside_ignored_tags(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <script type="text/javascript">
         $('#llist').tabs({
           remote: true,
           spinner: "${_('Please wait...')}"
         });
       </script>
     </html>""")
     results = list(extract(buf, ['_'], [], {}))
     self.assertEqual([
         (5, '_', u'Please wait...', []),
     ], results)
Exemplo n.º 10
0
 def test_extraction_inside_ignored_tags(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <script type="text/javascript">
         $('#llist').tabs({
           remote: true,
           spinner: "${_('Please wait...')}"
         });
       </script>
     </html>""")
     results = list(extract(buf, ['_'], [], {}))
     self.assertEqual([
         (5, '_', u'Please wait...', []),
     ], results)
Exemplo n.º 11
0
 def test_text_template_extraction(self):
     buf = StringIO("""${_("Dear %(name)s") % {'name': name}},
     
     ${ngettext("Your item:", "Your items", len(items))}
     #for item in items
      * $item
     #end
     
     All the best,
     Foobar""")
     results = list(
         extract(buf, ['_', 'ngettext'], [],
                 {'template_class': 'genshi.template:TextTemplate'}))
     self.assertEqual([(1, '_', u'Dear %(name)s', []),
                       (3, 'ngettext', (u'Your item:', u'Your items'), []),
                       (7, None, u'All the best,\n        Foobar', [])],
                      results)
Exemplo n.º 12
0
Arquivo: i18n.py Projeto: alon/polinax
 def test_text_template_extraction(self):
     buf = StringIO("""${_("Dear %(name)s") % {'name': name}},
     
     ${ngettext("Your item:", "Your items", len(items))}
     #for item in items
      * $item
     #end
     
     All the best,
     Foobar""")
     results = list(extract(buf, ['_', 'ngettext'], [], {
         'template_class': 'genshi.template:TextTemplate'
     }))
     self.assertEqual([
         (1, '_', u'Dear %(name)s', []),
         (3, 'ngettext', (u'Your item:', u'Your items', None), []),
         (7, None, u'All the best,\n        Foobar', [])
     ], results)
Exemplo n.º 13
0
 def test_markup_template_extraction(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <head>
         <title>Example</title>
       </head>
       <body>
         <h1>Example</h1>
         <p>${_("Hello, %(name)s") % dict(name=username)}</p>
         <p>${ngettext("You have %d item", "You have %d items", num)}</p>
       </body>
     </html>""")
     results = list(extract(buf, ['_', 'ngettext'], [], {}))
     self.assertEqual([
         (3, None, u'Example', []),
         (6, None, u'Example', []),
         (7, '_', u'Hello, %(name)s', []),
         (8, 'ngettext', (u'You have %d item', u'You have %d items'), []),
     ], results)
Exemplo n.º 14
0
Arquivo: i18n.py Projeto: alon/polinax
 def test_markup_template_extraction(self):
     buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
       <head>
         <title>Example</title>
       </head>
       <body>
         <h1>Example</h1>
         <p>${_("Hello, %(name)s") % dict(name=username)}</p>
         <p>${ngettext("You have %d item", "You have %d items", num)}</p>
       </body>
     </html>""")
     results = list(extract(buf, ['_', 'ngettext'], [], {}))
     self.assertEqual([
         (3, None, u'Example', []),
         (6, None, u'Example', []),
         (7, '_', u'Hello, %(name)s', []),
         (8, 'ngettext', (u'You have %d item', u'You have %d items', None),
                          []),
     ], results)