Esempio n. 1
0
File: i18n.py Progetto: 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)
Esempio 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)
Esempio n. 3
0
File: i18n.py Progetto: 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)
Esempio 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)
Esempio n. 5
0
File: i18n.py Progetto: 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, ['_'], [], {})))
Esempio 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, ['_'], [], {})))
Esempio 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)
Esempio n. 8
0
File: i18n.py Progetto: 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)
Esempio n. 9
0
File: i18n.py Progetto: 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)
Esempio 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)
Esempio 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)
Esempio n. 12
0
File: i18n.py Progetto: 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)
Esempio 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)
Esempio n. 14
0
File: i18n.py Progetto: 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)