Beispiel #1
0
    def test_pre(self):
        """Test raw content."""
        doc = HTMLFile(string='<pre>   This is raw text, "     \n"' ' </pre>')

        messages = [unit[0] for unit in doc.get_units()]
        expected = [((TEXT, u'This is raw text, "     \n"'), )]
        self.assertEqual(messages, expected)
Beispiel #2
0
    def test_pre(self):
        """Test raw content."""
        doc = HTMLFile(string = '<pre>   This is raw text, "     \n"'
                                ' </pre>')

        messages = [unit[0] for unit in doc.get_units()]
        expected = [((TEXT, u'This is raw text, "     \n"'),)]
        self.assertEqual(messages, expected)
Beispiel #3
0
    def test_case3(self):
        """Test complex attribute."""
        doc = HTMLFile(string='<html>\n'
                       '<input type="text" name="id">\n'
                       '<input type="submit" value="Change">\n'
                       '</html>')

        messages = [unit[0] for unit in doc.get_units()]
        self.assertEqual(messages, [((TEXT, u'Change'), )])
Beispiel #4
0
    def test_case4(self):
        """Test translation of an element content"""
        doc = HTMLFile(string='<p>hello world</p>')

        p = POFile(string='msgctxt "paragraph"\n'
                   'msgid "hello world"\n'
                   'msgstr "hola mundo"')

        self.assertEqual(doc.translate(p), '<p>hola mundo</p>')
Beispiel #5
0
    def test_case4(self):
        """Test translation of an element content"""
        doc = HTMLFile(string='<p>hello world</p>')

        p = POFile(string=
            'msgctxt "paragraph"\n'
            'msgid "hello world"\n'
            'msgstr "hola mundo"')

        self.assertEqual(doc.translate(p), '<p>hola mundo</p>')
Beispiel #6
0
    def test_translation1(self):
        """Test translation with surrounding tags"""

        doc = HTMLFile(string='<em>hello world</em>')

        p = POFile(string='msgctxt "emphasis"\n'
                   'msgid "hello world"\n'
                   'msgstr "hola mundo"')

        self.assertEqual(doc.translate(p), '<em>hola mundo</em>')
Beispiel #7
0
    def test_case3(self):
        """Test complex attribute."""
        doc = HTMLFile(string=
            '<html>\n'
            '<input type="text" name="id">\n'
            '<input type="submit" value="Change">\n'
            '</html>')

        messages = [unit[0] for unit in doc.get_units()]
        self.assertEqual(messages, [((TEXT, u'Change'),)])
Beispiel #8
0
    def test_translation1(self):
        """Test translation with surrounding tags"""

        doc = HTMLFile(string='<em>hello world</em>')

        p = POFile(string=
            'msgctxt "emphasis"\n'
            'msgid "hello world"\n'
            'msgstr "hola mundo"')

        self.assertEqual(doc.translate(p), '<em>hola mundo</em>')
Beispiel #9
0
    def test_case5(self):
        """Test translation of an element content"""
        doc = HTMLFile(string='<img alt="The beach" src="beach.jpg">')

        po = POFile(string='msgctxt "img[alt]"\n'
                    'msgid "The beach"\n'
                    'msgstr "La playa"')

        string = doc.translate(po)
        output = HTMLFile(string=string)

        expected = HTMLFile(string='<img alt="La playa" src="beach.jpg">')
        self.assertEqual(output, expected)
Beispiel #10
0
    def test_case5(self):
        """Test translation of an element content"""
        doc = HTMLFile(string='<img alt="The beach" src="beach.jpg">')

        po = POFile(string=
            'msgctxt "img[alt]"\n'
            'msgid "The beach"\n'
            'msgstr "La playa"')

        string = doc.translate(po)
        output = HTMLFile(string=string)

        expected = HTMLFile(string='<img alt="La playa" src="beach.jpg">')
        self.assertEqual(output, expected)
Beispiel #11
0
    def test_translation2(self):
        """Test translation with surrounding tags (2)"""

        doc = HTMLFile(string='Say: <em>hello world. It\'s me.</em>')

        p = POFile(string='msgid "Say:"\n'
                   'msgstr "Dice:"\n\n'
                   'msgctxt "emphasis"\n'
                   'msgid "hello world."\n'
                   'msgstr "hola mundo."\n\n'
                   'msgctxt "emphasis"\n'
                   'msgid "It\'s me."\n'
                   'msgstr "Es me."')

        self.assertEqual(doc.translate(p), 'Dice: <em>hola mundo. Es me.</em>')
Beispiel #12
0
    def test_case6(self):
        """Test translation of an element content"""
        doc = HTMLFile(string='<input type="text" name="id">'
                       '<input type="submit" value="Change">')

        p = POFile(string='msgctxt "button"\n'
                   'msgid "Change"\n'
                   'msgstr "Cambiar"')

        output = HTMLFile(string=doc.translate(p))

        expected = HTMLFile(string='<input type="text" name="id">'
                            '<input type="submit" value="Cambiar">')
        self.assertEqual(output.to_str(), expected.to_str())
Beispiel #13
0
    def test_translation2(self):
        """Test translation with surrounding tags (2)"""

        doc = HTMLFile(string =
            'Say: <em>hello world. It\'s me.</em>')

        p = POFile(string=
            'msgid "Say:"\n'
            'msgstr "Dice:"\n\n'
            'msgctxt "emphasis"\n'
            'msgid "hello world."\n'
            'msgstr "hola mundo."\n\n'
            'msgctxt "emphasis"\n'
            'msgid "It\'s me."\n'
            'msgstr "Es me."')

        self.assertEqual(doc.translate(p),
                         'Dice: <em>hola mundo. Es me.</em>')
Beispiel #14
0
    def test_translation4(self):
        """Test translation with surrounding tags (4)"""

        doc = HTMLFile(string='Say: <em>   hello world. It\'s me.</em>'
                       '      Do you remember me ? ')

        p = POFile(string='msgid "Say:"\n'
                   'msgstr "Dites:"\n\n'
                   'msgctxt "emphasis"\n'
                   'msgid "hello world."\n'
                   'msgstr "Bonjour monde."\n\n'
                   'msgctxt "emphasis"\n'
                   'msgid "It\'s me."\n'
                   'msgstr "C\'est moi."\n\n'
                   'msgid "Do you remember me ?"\n'
                   'msgstr "Vous vous rappelez de moi ?"')

        self.assertEqual(
            doc.translate(p), 'Dites: '
            '<em>   Bonjour monde. C\'est moi.</em>'
            '      Vous vous rappelez de moi ? ')
Beispiel #15
0
    def test_translation3(self):
        """Test translation with surrounding tags (3)"""

        doc = HTMLFile(string =
            'Say: <em> hello world. It\'s me.</em> Do you remember me ?')

        p = POFile(string=
            'msgid "Say:"\n'
            'msgstr "Dites:"\n\n'
            'msgctxt "emphasis"\n'
            'msgid "hello world."\n'
            'msgstr "Bonjour monde."\n\n'
            'msgctxt "emphasis"\n'
            'msgid "It\'s me."\n'
            'msgstr "C\'est moi."\n\n'
            'msgid "Do you remember me ?"\n'
            'msgstr "Vous vous rappelez de moi ?"')

        self.assertEqual(doc.translate(p),
                         'Dites: <em> Bonjour monde. C\'est moi.</em> '
                         'Vous vous rappelez de moi ?')
Beispiel #16
0
    def test_case6(self):
        """Test translation of an element content"""
        doc = HTMLFile(string=
            '<input type="text" name="id">'
            '<input type="submit" value="Change">')

        p = POFile(string=
            'msgctxt "button"\n'
            'msgid "Change"\n'
            'msgstr "Cambiar"')

        output = HTMLFile(string=doc.translate(p))

        expected = HTMLFile(string=
            '<input type="text" name="id">'
            '<input type="submit" value="Cambiar">')
        self.assertEqual(output.to_str(), expected.to_str())
Beispiel #17
0
    def test_case1(self):
        """Test element content."""
        doc = HTMLFile(string='<p>hello world</p>')

        messages = [unit[0] for unit in doc.get_units()]
        self.assertEqual(messages, [((TEXT, u'hello world'),)])
Beispiel #18
0
    def test_case2(self):
        """Test simple attribute."""
        doc = HTMLFile(string='<img alt="The beach" src="beach.jpg">')

        messages = [unit[0] for unit in doc.get_units()]
        self.assertEqual(messages, [((TEXT, u'The beach'), )])
Beispiel #19
0
    def test_case1(self):
        """Test element content."""
        doc = HTMLFile(string='<p>hello world</p>')

        messages = [unit[0] for unit in doc.get_units()]
        self.assertEqual(messages, [((TEXT, u'hello world'), )])
Beispiel #20
0
    def test_case2(self):
        """Test simple attribute."""
        doc = HTMLFile(string='<img alt="The beach" src="beach.jpg">')

        messages = [unit[0] for unit in doc.get_units()]
        self.assertEqual(messages, [((TEXT, u'The beach'),)])