Example #1
0
    def test_basic(self):
        minipo = r"""# Afrikaans translation of program ABC
#
msgid ""
msgstr ""
"Project-Id-Version: program 2.1-branch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-01-09 07:15+0100\n"
"PO-Revision-Date: 2004-03-30 17:02+0200\n"
"Last-Translator: Zuza Software Foundation <*****@*****.**>\n"
"Language-Team: Afrikaans <*****@*****.**>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

# Please remember to do something
#: ../dir/file.xml.in.h:1 ../dir/file2.xml.in.h:4
msgid "Applications"
msgstr "Toepassings"
"""
        tmx = self.po2tmx(minipo)
        print "The generated xml:"
        print str(tmx)
        assert tmx.translate("Applications") == "Toepassings"
        assert tmx.translate("bla") is None
        xmltext = str(tmx)
        assert xmltext.index('creationtool="Translate Toolkit - po2tmx"')
        assert xmltext.index('adminlang')
        assert xmltext.index('creationtoolversion')
        assert xmltext.index('datatype')
        assert xmltext.index('o-tmf')
        assert xmltext.index('segtype')
        assert xmltext.index('srclang')
Example #2
0
    def test_basic(self):
        minipo = r"""# Afrikaans translation of program ABC
#
msgid ""
msgstr ""
"Project-Id-Version: program 2.1-branch\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-01-09 07:15+0100\n"
"PO-Revision-Date: 2004-03-30 17:02+0200\n"
"Last-Translator: Zuza Software Foundation <*****@*****.**>\n"
"Language-Team: Afrikaans <*****@*****.**>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

# Please remember to do something
#: ../dir/file.xml.in.h:1 ../dir/file2.xml.in.h:4
msgid "Applications"
msgstr "Toepassings"
"""
        tmx = self.po2tmx(minipo)
        print("The generated xml:")
        print(bytes(tmx))
        assert tmx.translate("Applications") == "Toepassings"
        assert tmx.translate("bla") is None
        xmltext = bytes(tmx).decode('utf-8')
        assert xmltext.index('creationtool="Translate Toolkit"')
        assert xmltext.index('adminlang')
        assert xmltext.index('creationtoolversion')
        assert xmltext.index('datatype')
        assert xmltext.index('o-tmf')
        assert xmltext.index('segtype')
        assert xmltext.index('srclang')
Example #3
0
    def test_escapedquotes(self):
        """Test the escaping of quotes (and slash)"""
        minipo = r'''msgid "Hello \"Everyone\""
msgstr "Good day \"All\""

msgid "Use \\\"."
msgstr "Gebruik \\\"."
'''
        tmx = self.po2tmx(minipo)
        print("The generated xml:")
        print(bytes(tmx))
        assert tmx.translate('Hello "Everyone"') == 'Good day "All"'
        assert tmx.translate(r'Use \".') == r'Gebruik \".'
Example #4
0
    def test_escapedquotes(self):
        """Test the escaping of quotes (and slash)"""
        minipo = r'''msgid "Hello \"Everyone\""
msgstr "Good day \"All\""

msgid "Use \\\"."
msgstr "Gebruik \\\"."
'''
        tmx = self.po2tmx(minipo)
        print "The generated xml:"
        print str(tmx)
        assert tmx.translate('Hello "Everyone"') == 'Good day "All"'
        assert tmx.translate(r'Use \".') == r'Gebruik \".'
Example #5
0
    def test_nonascii(self):
        """Tests that non-ascii conversion works."""
        minipo = u'''msgid "Bézier curve"
msgstr "Bézier-kurwe"
'''
        tmx = self.po2tmx(minipo)
        print(bytes(tmx))
        assert tmx.translate(u"Bézier curve") == u"Bézier-kurwe"
Example #6
0
    def test_nonascii(self):
        """Tests that non-ascii conversion works."""
        minipo = r'''msgid "Bézier curve"
msgstr "Bézier-kurwe"
'''
        tmx = self.po2tmx(minipo)
        print str(tmx)
        assert tmx.translate(u"Bézier curve") == u"Bézier-kurwe"
Example #7
0
    def test_nonascii(self):
        """Tests that non-ascii conversion works."""
        minipo = """msgid "Bézier curve"
msgstr "Bézier-kurwe"
"""
        tmx = self.po2tmx(minipo)
        print(bytes(tmx))
        assert tmx.translate("Bézier curve") == "Bézier-kurwe"
Example #8
0
    def test_escapedtabs(self):
        """Test the escaping of tabs"""
        minipo = r'''msgid "First column\tSecond column"
msgstr "Eerste kolom\tTweede kolom"
'''
        tmx = self.po2tmx(minipo)
        print("The generated xml:")
        print(bytes(tmx))
        assert tmx.translate("First column\tSecond column") == "Eerste kolom\tTweede kolom"
Example #9
0
    def test_escapednewlines(self):
        """Test the escaping of newlines"""
        minipo = r'''msgid "First line\nSecond line"
msgstr "Eerste lyn\nTweede lyn"
'''
        tmx = self.po2tmx(minipo)
        print("The generated xml:")
        print(bytes(tmx))
        assert tmx.translate("First line\nSecond line") == "Eerste lyn\nTweede lyn"
Example #10
0
    def test_escapedtabs(self):
        """Test the escaping of tabs"""
        minipo = r'''msgid "First column\tSecond column"
msgstr "Eerste kolom\tTweede kolom"
'''
        tmx = self.po2tmx(minipo)
        print "The generated xml:"
        print str(tmx)
        assert tmx.translate("First column\tSecond column") == "Eerste kolom\tTweede kolom"
Example #11
0
    def test_escapednewlines(self):
        """Test the escaping of newlines"""
        minipo = r'''msgid "First line\nSecond line"
msgstr "Eerste lyn\nTweede lyn"
'''
        tmx = self.po2tmx(minipo)
        print "The generated xml:"
        print str(tmx)
        assert tmx.translate("First line\nSecond line") == "Eerste lyn\nTweede lyn"
Example #12
0
    def test_multiline(self):
        """Test multiline po entry"""
        minipo = r'''msgid "First part "
"and extra"
msgstr "Eerste deel "
"en ekstra"'''
        tmx = self.po2tmx(minipo)
        print("The generated xml:")
        print(bytes(tmx))
        assert tmx.translate('First part and extra') == 'Eerste deel en ekstra'
Example #13
0
    def test_multiline(self):
        """Test multiline po entry"""
        minipo = r'''msgid "First part "
"and extra"
msgstr "Eerste deel "
"en ekstra"'''
        tmx = self.po2tmx(minipo)
        print "The generated xml:"
        print str(tmx)
        assert tmx.translate('First part and extra') == 'Eerste deel en ekstra'
Example #14
0
    def test_escapedtabs(self):
        """Test the escaping of tabs"""
        minipo = r"""msgid "First column\tSecond column"
msgstr "Eerste kolom\tTweede kolom"
"""
        tmx = self.po2tmx(minipo)
        print("The generated xml:")
        print(bytes(tmx))
        assert (tmx.translate("First column\tSecond column") ==
                "Eerste kolom\tTweede kolom")