Exemplo n.º 1
0
 def test_plural_translation(self):
     po_file = PoFile()
     entry = po_file.add_entry("message", "plural")
     entry.add_plural_translation(0, "translation")
     entry.add_plural_translation(1, "plural translation")
     self.assertEqual({0: "translation", 1: "plural translation"}, entry.translations)
     self.assertEqual(
         {
             ("message", 0): "translation",
             ("message", 1): "plural translation"},
         po_file.get_catalog())
Exemplo n.º 2
0
 def test_plural_translation(self):
     po_file = PoFile()
     entry = po_file.add_entry("message", "plural")
     entry.add_plural_translation(0, "translation")
     entry.add_plural_translation(1, "plural translation")
     self.assertEqual({
         0: "translation",
         1: "plural translation"
     }, entry.translations)
     self.assertEqual(
         {
             ("message", 0): "translation",
             ("message", 1): "plural translation"
         }, po_file.get_catalog())
Exemplo n.º 3
0
 def test_catalog(self):
     po_file = PoFile()
     po_file.add_entry("non translated message")
     po_file.add_entry("translated message").add_translation("translation")
     entry = po_file.add_entry("translated message 2", "plural")
     entry.add_plural_translation(0, "translation 2")
     entry.add_plural_translation(1, "plural translation 2")
     po_file.add_entry("translated message 3", context="context").add_translation("translation 3")
     entry = po_file.add_entry("translated message 4", "plural", "context")
     entry.add_plural_translation(0, "translation 4")
     entry.add_plural_translation(1, "plural translation 4")
     self.assertEqual(
         {
             "translated message": "translation",
             ("translated message 2", 0): "translation 2",
             ("translated message 2", 1): "plural translation 2",
             "context\x04translated message 3": "translation 3",
             ("context\x04translated message 4", 0): "translation 4",
             ("context\x04translated message 4", 1): "plural translation 4"},
         po_file.get_catalog())
Exemplo n.º 4
0
 def test_catalog(self):
     po_file = PoFile()
     po_file.add_entry("non translated message")
     po_file.add_entry("translated message").add_translation("translation")
     entry = po_file.add_entry("translated message 2", "plural")
     entry.add_plural_translation(0, "translation 2")
     entry.add_plural_translation(1, "plural translation 2")
     po_file.add_entry("translated message 3",
                       context="context").add_translation("translation 3")
     entry = po_file.add_entry("translated message 4", "plural", "context")
     entry.add_plural_translation(0, "translation 4")
     entry.add_plural_translation(1, "plural translation 4")
     self.assertEqual(
         {
             "translated message": "translation",
             ("translated message 2", 0): "translation 2",
             ("translated message 2", 1): "plural translation 2",
             "context\x04translated message 3": "translation 3",
             ("context\x04translated message 4", 0): "translation 4",
             ("context\x04translated message 4", 1): "plural translation 4"
         }, po_file.get_catalog())
Exemplo n.º 5
0
def parse_po_file(fp, filename=None):
    po_file = PoFile()
    Parser(po_file).parse_po_file(fp, filename)
    return po_file.get_catalog()
Exemplo n.º 6
0
 def test_translation(self):
     po_file = PoFile()
     entry = po_file.add_entry("message")
     entry.add_translation("translation")
     self.assertEqual({0: "translation"}, entry.translations)
     self.assertEqual({"message": "translation"}, po_file.get_catalog())
Exemplo n.º 7
0
 def test_translation(self):
     po_file = PoFile()
     entry = po_file.add_entry("message")
     entry.add_translation("translation")
     self.assertEqual({0: "translation"}, entry.translations)
     self.assertEqual({"message": "translation"}, po_file.get_catalog())
Exemplo n.º 8
0
def parse_po_file(fp, filename=None):
    po_file = PoFile()
    Parser(po_file).parse_po_file(fp, filename)
    return po_file.get_catalog()