示例#1
0
def precommit(committedfile, author, message):
    if os.path.basename(committedfile) == "language.po":

        # Get the files we'll be using
        tikifile = os.path.join(os.path.dirname(committedfile), 'language.php')

        # Update tikifile with new strings
        print "Converting po to tiki: %s to %s" % (committedfile, tikifile)
        po2tiki.convertpo(open(committedfile, "r"), open(tikifile, "w"))

        # We want to commit messages.php
        return [tikifile]
    return []
示例#2
0
文件: sumo.py 项目: ENuge/pootle
def precommit(committedfile, author, message):
    if os.path.basename(committedfile) == "language.po":

        # Get the files we'll be using
        tikifile = os.path.join(os.path.dirname(committedfile), "language.php")

        # Update tikifile with new strings
        print "Converting po to tiki: %s to %s" % (committedfile, tikifile)
        po2tiki.convertpo(open(committedfile, "r"), open(tikifile, "w"))

        # We want to commit messages.php
        return [tikifile]
    return []
示例#3
0
    def test_convertpo(self):
        inputfile = """
#: translated
msgid "zero_source"
msgstr "zero_target"

#: unused
msgid "one_source"
msgstr "one_target"
        """
        outputfile = wStringIO.StringIO()
        po2tiki.convertpo(inputfile, outputfile)

        output = outputfile.getvalue()

        assert '"one_source" => "one_target",' in output
        assert '"zero_source" => "zero_target",' in output
示例#4
0
    def test_convertpo(self):
        inputfile = b"""
#: translated
msgid "zero_source"
msgstr "zero_target"

#: unused
msgid "one_source"
msgstr "one_target"
        """
        outputfile = BytesIO()
        po2tiki.convertpo(inputfile, outputfile)

        output = outputfile.getvalue().decode("utf-8")

        assert '"one_source" => "one_target",' in output
        assert '"zero_source" => "zero_target",' in output
示例#5
0
    def test_convertpo(self):
        inputfile = """
#: translated
msgid "zero_source"
msgstr "zero_target"

#: unused
msgid "one_source"
msgstr "one_target"
        """
        outputfile = wStringIO.StringIO()
        po2tiki.convertpo(inputfile, outputfile)

        output = outputfile.getvalue()

        assert '"one_source" => "one_target",' in output
        assert '"zero_source" => "zero_target",' in output
示例#6
0
    def test_convertpo(self):
        inputfile = b"""
#: translated
msgid "zero_source"
msgstr "zero_target"

#: unused
msgid "one_source"
msgstr "one_target"
        """
        outputfile = BytesIO()
        po2tiki.convertpo(inputfile, outputfile)

        output = outputfile.getvalue().decode('utf-8')

        assert '"one_source" => "one_target",' in output
        assert '"zero_source" => "zero_target",' in output