Example #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>')
Example #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>')
Example #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>')
Example #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>')
Example #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)
Example #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())
Example #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)
Example #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>')
Example #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())
Example #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>')
Example #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 ? ')
Example #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 ?')