コード例 #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)
コード例 #2
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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)
コード例 #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'), )])
コード例 #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>')
コード例 #5
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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>')
コード例 #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>')
コード例 #7
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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'),)])
コード例 #8
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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>')
コード例 #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)
コード例 #10
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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)
コード例 #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>')
コード例 #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())
コード例 #13
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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>')
コード例 #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 ? ')
コード例 #15
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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 ?')
コード例 #16
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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())
コード例 #17
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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'),)])
コード例 #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'), )])
コード例 #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'), )])
コード例 #20
0
ファイル: test_html.py プロジェクト: Nabellaleen/itools
    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'),)])