コード例 #1
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_translated_unicode(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "bar"
}
""")
        f.flush()

        tf = tempfile.NamedTemporaryFile(mode="w+")
        tf.write(r"""
{
	"foo": "★"
}
""")
        tf.flush()

        out = arb2po(f.name, tf.name)
        f.close()
        tf.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#, no-c-format
msgctxt "foo"
msgid "bar"
msgstr "★"
""".rstrip())
コード例 #2
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_plural_escape_apostrophes(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "{param, plural, =1{singular} other{'' plural}}",
	"@foo": {
		"placeholders": {
			"param": {}
		}
	}
}
""")
        f.flush()
        out = arb2po(f.name, None)
        f.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#. Parameter 1: param
#, c-format
msgctxt "foo"
msgid "singular"
msgid_plural "' plural"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
msgstr[3] ""
""".rstrip())
コード例 #3
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_two_parameters(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "{param1} bar {param2}",
	"@foo": {
		"placeholders": {
			"param1": {},
			"param2": {}
		}
	}
}
""")
        f.flush()
        out = arb2po(f.name, None)
        f.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#. Parameter 1: param1
#. Parameter 2: param2
#, c-format
msgctxt "foo"
msgid "%1$s bar %2$s"
msgstr ""
""".rstrip())
コード例 #4
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
 def test_header(self):
     f = tempfile.NamedTemporaryFile(mode="w+")
     f.write("{}")
     f.flush()
     out = arb2po(f.name, None)
     f.close()
     self.assertEqual(out.strip(), _HEADER)
コード例 #5
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_parameter_example(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "{param} bar",
	"@foo": {
		"placeholders": {
			"param": {
				"example": "hello"
			}
		}
	}
}
""")
        f.flush()
        out = arb2po(f.name, None)
        f.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#. Parameter 1: param (example: hello)
#, c-format
msgctxt "foo"
msgid "%1$s bar"
msgstr ""
""".rstrip())
コード例 #6
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_escape(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "bar\\bar"
}
""")
        f.flush()
        out = arb2po(f.name, None)
        f.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#, no-c-format
msgctxt "foo"
msgid "bar\\bar"
msgstr ""
""".rstrip())
コード例 #7
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_translated_plural_one_parameter(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "{param, plural, =1{singular} other{{param} plural}}",
	"@foo": {
		"placeholders": {
			"param": {}
		}
	}
}
""")
        f.flush()

        tf = tempfile.NamedTemporaryFile(mode="w+")
        tf.write(r"""
{
	"foo": "{param, plural, =0{zero {param}} =1{one {param}} =2{two {param}} other{many {param}}}",
	"@foo": {
		"placeholders": {
			"param": {}
		}
	}
}
""")
        tf.flush()

        out = arb2po(f.name, tf.name)
        f.close()
        tf.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#. Parameter 1: param
#, c-format
msgctxt "foo"
msgid "singular"
msgid_plural "%1$s plural"
msgstr[0] "zero %1$s"
msgstr[1] "one %1$s"
msgstr[2] "two %1$s"
msgstr[3] "many %1$s"
""".rstrip())
コード例 #8
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_translated_plural_basic_other(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "{param, plural, =1{singular} other{plural}}",
	"@foo": {
		"placeholders": {
			"param": {}
		}
	}
}
""")
        f.flush()

        tf = tempfile.NamedTemporaryFile(mode="w+")
        tf.write(r"""
{
	"foo": "{param, plural, other{many}}",
	"@foo": {
		"placeholders": {
			"param": {}
		}
	}
}
""")
        tf.flush()

        out = arb2po(f.name, tf.name)
        f.close()
        tf.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#. Parameter 1: param
#, c-format
msgctxt "foo"
msgid "singular"
msgid_plural "plural"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
msgstr[3] "many"
""".rstrip())
コード例 #9
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_translated_one_parameter(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "{param} bar",
	"@foo": {
		"placeholders": {
			"param": {}
		}
	}
}
""")
        f.flush()

        tf = tempfile.NamedTemporaryFile(mode="w+")
        tf.write(r"""
{
	"foo": "{param} translated",
	"@foo": {
		"placeholders": {
			"param": {}
		}
	}
}
""")
        tf.flush()

        out = arb2po(f.name, tf.name)
        f.close()
        tf.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#. Parameter 1: param
#, c-format
msgctxt "foo"
msgid "%1$s bar"
msgstr "%1$s translated"
""".rstrip())
コード例 #10
0
ファイル: test_arb2po.py プロジェクト: nkming2/arb2po
    def test_decription(self):
        f = tempfile.NamedTemporaryFile(mode="w+")
        f.write(r"""
{
	"foo": "bar",
	"@foo": {
		"description": "hello world"
	}
}
""")
        f.flush()
        out = arb2po(f.name, None)
        f.close()
        self.assertEqual(
            out.strip(), _HEADER + r"""

#. hello world
#, no-c-format
msgctxt "foo"
msgid "bar"
msgstr ""
""".rstrip())