Ejemplo n.º 1
0
 def roundtripstring(self, entitystring):
     oointro, oooutro = (
         r"svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	",
         "				2002-02-02 02:02:02" + "\r\n",
     )
     oosource = oointro + entitystring + oooutro
     ooinputfile = BytesIO(oosource.encode())
     ooinputfile2 = BytesIO(oosource.encode())
     pooutputfile = BytesIO()
     oo2po.convertoo(ooinputfile,
                     pooutputfile,
                     ooinputfile2,
                     targetlanguage="en-US")
     posource = pooutputfile.getvalue()
     poinputfile = BytesIO(posource)
     ootemplatefile = BytesIO(oosource.encode())
     oooutputfile = BytesIO()
     po2oo.convertoo(poinputfile,
                     oooutputfile,
                     ootemplatefile,
                     targetlanguage="en-US")
     ooresult = oooutputfile.getvalue().decode("utf-8")
     print(
         "original oo:\n",
         oosource,
         "po version:\n",
         posource,
         "output oo:\n",
         ooresult,
     )
     assert ooresult.startswith(oointro) and ooresult.endswith(oooutro)
     return ooresult[len(oointro):-len(oooutro)]
Ejemplo n.º 2
0
    def roundtripstring(self, filename, entitystring):
        """
        Convert the supplied string as part of an OpenOffice.org GSI file to po and back.

        Return the string once it has been through all the conversions.
        """

        ootemplate = r'helpcontent2	%s	0	help	par_id3150670 35				0	en-US	%s				2002-02-02 02:02:02'

        oosource = (ootemplate % (filename, entitystring)).encode('utf-8')
        ooinputfile = BytesIO(oosource)
        ootemplatefile = BytesIO(oosource)
        pooutputfile = BytesIO()

        self.conversion_module.convertoo(ooinputfile,
                                         pooutputfile,
                                         ootemplatefile,
                                         targetlanguage='en-US')
        posource = pooutputfile.getvalue()

        poinputfile = BytesIO(posource)
        ootemplatefile = BytesIO(oosource)
        oooutputfile = BytesIO()
        po2oo.convertoo(poinputfile,
                        oooutputfile,
                        ootemplatefile,
                        targetlanguage="en-US")
        ooresult = oooutputfile.getvalue().decode('utf-8')
        print("original oo:\n", oosource, "po version:\n", posource,
              "output oo:\n", ooresult)
        return ooresult.split('\t')[10]
Ejemplo n.º 3
0
 def convertoo(self, posource, ootemplate, language="en-US"):
     """helper to exercise the command line function"""
     inputfile = wStringIO.StringIO(posource)
     outputfile = wStringIO.StringIO()
     templatefile = wStringIO.StringIO(ootemplate)
     assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage=language, timestamp=0)
     return outputfile.getvalue()
Ejemplo n.º 4
0
    def test_helpcontent_escapes(self):
        """test to ensure that we convert helpcontent escapes correctly"""
        # Note how this test specifically uses incorrect spacing in the
        # translation. The extra space before 'hid' and an extra space before
        # the closing tag should not confuse us.
        oosource = (
            r"helpcontent2	source\text\shared\3dsettings_toolbar.xhp	0	help	par_idN1056A				0	en-US	\<ahelp hid=\".\"\>The 3D-Settings toolbar controls properties of selected 3D objects.\</ahelp\>				2002-02-02 02:02:02"
            + "\r\n")
        posource = r"""#: 3dsettings_toolbar.xhp#par_idN1056A.help.text
msgid ""
"<ahelp hid=\".\">The 3D-Settings toolbar controls properties of selected 3D "
"ob jects.</ahelp>"
msgstr ""
"<ahelp  hid=\".\" >Zeee 3DDDD-Settings toolbar controls properties of selected 3D "
"objects.</ahelp>"
"""
        inputfile = BytesIO(posource.encode())
        outputfile = BytesIO()
        templatefile = BytesIO(oosource.encode())
        assert po2oo.convertoo(inputfile,
                               outputfile,
                               templatefile,
                               targetlanguage="af-ZA")
        assert (
            br"\<ahelp  hid=\".\" \>Zeee 3DDDD-Settings toolbar controls properties of selected 3D objects.\</ahelp\>"
            in outputfile.getvalue())
Ejemplo n.º 5
0
 def roundtripstring(self, entitystring):
     oointro, oooutro = r'svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	', '				2002-02-02 02:02:02' + '\r\n'
     oosource = oointro + entitystring + oooutro
     ooinputfile = wStringIO.StringIO(oosource)
     ooinputfile2 = wStringIO.StringIO(oosource)
     pooutputfile = wStringIO.StringIO()
     oo2po.convertoo(ooinputfile, pooutputfile, ooinputfile2, targetlanguage='en-US')
     posource = pooutputfile.getvalue()
     poinputfile = wStringIO.StringIO(posource)
     ootemplatefile = wStringIO.StringIO(oosource)
     oooutputfile = wStringIO.StringIO()
     po2oo.convertoo(poinputfile, oooutputfile, ootemplatefile, targetlanguage="en-US")
     ooresult = oooutputfile.getvalue().decode('utf-8')
     print("original oo:\n", oosource, "po version:\n", posource, "output oo:\n", ooresult)
     assert ooresult.startswith(oointro) and ooresult.endswith(oooutro)
     return ooresult[len(oointro):-len(oooutro)]
Ejemplo n.º 6
0
 def convertoo(self, posource, ootemplate, language="en-US"):
     """helper to exercise the command line function"""
     inputfile = BytesIO(posource.encode())
     outputfile = BytesIO()
     templatefile = BytesIO(ootemplate.encode())
     assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage=language, timestamp=0)
     return outputfile.getvalue()
Ejemplo n.º 7
0
 def test_escape_conversion(self):
     """test to ensure that we convert escapes correctly"""
     oosource = r'svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	Column1\tColumn2\r\n				2002-02-02 02:02:02' + '\r\n'
     posource = '''#: numpages.src#RID_SVXPAGE_NUM_OPTIONS.STR_BULLET.string.text\nmsgid "Column1\\tColumn2\\r\\n"\nmsgstr "Kolom1\\tKolom2\\r\\n"\n'''
     inputfile = wStringIO.StringIO(posource)
     outputfile = wStringIO.StringIO()
     templatefile = wStringIO.StringIO(oosource)
     assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage="af-ZA")
     assert b"\tKolom1\\tKolom2\\r\\n\t" in outputfile.getvalue()
Ejemplo n.º 8
0
 def test_default_timestamp(self):
     """test to ensure that we revert to the default timestamp"""
     oointro, oooutro = r'svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	Text				', '\r\n'
     posource = '''#: numpages.src#RID_SVXPAGE_NUM_OPTIONS.STR_BULLET.string.text\nmsgid "Text"\nmsgstr "Text"\n'''
     inputfile = wStringIO.StringIO(posource)
     outputfile = wStringIO.StringIO()
     templatefile = wStringIO.StringIO(oointro + '20050924 09:13:58' + oooutro)
     assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage="en-US")
     assert outputfile.getvalue().decode('utf-8') == oointro + '2002-02-02 02:02:02' + oooutro
Ejemplo n.º 9
0
 def test_escape_conversion(self):
     """test to ensure that we convert escapes correctly"""
     oosource = r'svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	Column1\tColumn2\r\n				2002-02-02 02:02:02' + '\r\n'
     posource = '''#: numpages.src#RID_SVXPAGE_NUM_OPTIONS.STR_BULLET.string.text\nmsgid "Column1\\tColumn2\\r\\n"\nmsgstr "Kolom1\\tKolom2\\r\\n"\n'''
     inputfile = BytesIO(posource.encode())
     outputfile = BytesIO()
     templatefile = BytesIO(oosource.encode())
     assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage="af-ZA")
     assert b"\tKolom1\\tKolom2\\r\\n\t" in outputfile.getvalue()
Ejemplo n.º 10
0
 def test_default_timestamp(self):
     """test to ensure that we revert to the default timestamp"""
     oointro, oooutro = r'svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	Text				', '\r\n'
     posource = '''#: numpages.src#RID_SVXPAGE_NUM_OPTIONS.STR_BULLET.string.text\nmsgid "Text"\nmsgstr "Text"\n'''
     inputfile = BytesIO(posource.encode())
     outputfile = BytesIO()
     templatefile = BytesIO((oointro + '20050924 09:13:58' + oooutro).encode())
     assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage="en-US")
     assert outputfile.getvalue().decode('utf-8') == oointro + '2002-02-02 02:02:02' + oooutro
Ejemplo n.º 11
0
    def test_helpcontent_escapes2(self):
        """test to ensure that we convert helpcontent escapes correctly"""
        oosource = r'helpcontent2	source\text\scalc\05\empty_cells.xhp	0	help	par_id2629474				0	en-US	A1: <empty>				2002-02-02 02:02:02' + '\r\n'
        posource = r'''#: empty_cells.xhp#par_id2629474.help.text
msgid "A1: <empty>"
msgstr "Aa1: <empty>"
'''
        inputfile = wStringIO.StringIO(posource)
        outputfile = wStringIO.StringIO()
        templatefile = wStringIO.StringIO(oosource)
        assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage="af-ZA")
        assert b"Aa1: <empty>" in outputfile.getvalue()
Ejemplo n.º 12
0
    def test_helpcontent_escapes2(self):
        """test to ensure that we convert helpcontent escapes correctly"""
        oosource = r'helpcontent2	source\text\scalc\05\empty_cells.xhp	0	help	par_id2629474				0	en-US	A1: <empty>				2002-02-02 02:02:02' + '\r\n'
        posource = r'''#: empty_cells.xhp#par_id2629474.help.text
msgid "A1: <empty>"
msgstr "Aa1: <empty>"
'''
        inputfile = BytesIO(posource.encode())
        outputfile = BytesIO()
        templatefile = BytesIO(oosource.encode())
        assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage="af-ZA")
        assert b"Aa1: <empty>" in outputfile.getvalue()
Ejemplo n.º 13
0
    def roundtripstring(self, filename, entitystring):
        """Convert the supplied string as part of an OpenOffice.org GSI file to po and back.

        Return the string once it has been through all the conversions."""

        ootemplate = r'helpcontent2	%s	0	help	par_id3150670 35				0	en-US	%s				2002-02-02 02:02:02'

        oosource = ootemplate % (filename, entitystring)
        ooinputfile = wStringIO.StringIO(oosource)
        ootemplatefile = wStringIO.StringIO(oosource)
        pooutputfile = wStringIO.StringIO()

        self.conversion_module.convertoo(ooinputfile, pooutputfile, ootemplatefile, targetlanguage='en-US')
        posource = pooutputfile.getvalue()

        poinputfile = wStringIO.StringIO(posource)
        ootemplatefile = wStringIO.StringIO(oosource)
        oooutputfile = wStringIO.StringIO()
        po2oo.convertoo(poinputfile, oooutputfile, ootemplatefile, targetlanguage="en-US")
        ooresult = oooutputfile.getvalue()
        print("original oo:\n", oosource, "po version:\n", posource, "output oo:\n", ooresult)
        return ooresult.split('\t')[10]
Ejemplo n.º 14
0
 def roundtripstring(self, entitystring):
     oointro, oooutro = r'svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	', '				2002-02-02 02:02:02' + '\r\n'
     oosource = oointro + entitystring + oooutro
     ooinputfile = wStringIO.StringIO(oosource)
     ooinputfile2 = wStringIO.StringIO(oosource)
     pooutputfile = wStringIO.StringIO()
     oo2po.convertoo(ooinputfile,
                     pooutputfile,
                     ooinputfile2,
                     targetlanguage='en-US')
     posource = pooutputfile.getvalue()
     poinputfile = wStringIO.StringIO(posource)
     ootemplatefile = wStringIO.StringIO(oosource)
     oooutputfile = wStringIO.StringIO()
     po2oo.convertoo(poinputfile,
                     oooutputfile,
                     ootemplatefile,
                     targetlanguage="en-US")
     ooresult = oooutputfile.getvalue()
     print "original oo:\n", oosource, "po version:\n", posource, "output oo:\n", ooresult
     assert ooresult.startswith(oointro) and ooresult.endswith(oooutro)
     return ooresult[len(oointro):-len(oooutro)]
Ejemplo n.º 15
0
    def test_helpcontent_escapes(self):
        """test to ensure that we convert helpcontent escapes correctly"""
        # Note how this test specifically uses incorrect spacing in the
        # translation. The extra space before 'hid' and an extra space before
        # the closing tag should not confuse us.
        oosource = r'helpcontent2	source\text\shared\3dsettings_toolbar.xhp	0	help	par_idN1056A				0	en-US	\<ahelp hid=\".\"\>The 3D-Settings toolbar controls properties of selected 3D objects.\</ahelp\>				2002-02-02 02:02:02' + '\r\n'
        posource = r'''#: 3dsettings_toolbar.xhp#par_idN1056A.help.text
msgid ""
"<ahelp hid=\".\">The 3D-Settings toolbar controls properties of selected 3D "
"ob jects.</ahelp>"
msgstr ""
"<ahelp  hid=\".\" >Zeee 3DDDD-Settings toolbar controls properties of selected 3D "
"objects.</ahelp>"
'''
        inputfile = wStringIO.StringIO(posource)
        outputfile = wStringIO.StringIO()
        templatefile = wStringIO.StringIO(oosource)
        assert po2oo.convertoo(inputfile, outputfile, templatefile, targetlanguage="af-ZA")
        assert br"\<ahelp  hid=\".\" \>Zeee 3DDDD-Settings toolbar controls properties of selected 3D objects.\</ahelp\>" in outputfile.getvalue()