Ejemplo n.º 1
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>')
Ejemplo n.º 2
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>')
Ejemplo n.º 3
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>')
Ejemplo n.º 4
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>')
Ejemplo n.º 5
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)
Ejemplo n.º 6
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())
Ejemplo n.º 7
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)
Ejemplo n.º 8
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>')
Ejemplo n.º 9
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())
Ejemplo n.º 10
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>')
Ejemplo n.º 11
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 ? ')
Ejemplo n.º 12
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 ?')