예제 #1
0
    def test_case1(self):
        """Test for newlines."""
        content = 'msgid "Add"\n' \
                  'msgstr "Ajouter\\n"\n'
        po = POFile()
        po.load_state_from_string(content)

        self.assertEqual(po.get_msgstr('Add'), u'Ajouter\n')
예제 #2
0
    def test_case3(self):
        """Test for double quotes."""
        content = 'msgid "test"\n' \
                  'msgstr "Esto es una \\"prueba\\""\n'
        po = POFile()
        po.load_state_from_string(content)

        self.assertEqual(po.get_msgstr('test'), u'Esto es una "prueba"')
예제 #3
0
    def test_case3(self):
        """Test for double quotes."""
        content = 'msgid "test"\n' \
                  'msgstr "Esto es una \\"prueba\\""\n'
        po = POFile()
        po.load_state_from_string(content)

        self.assertEqual(po.get_msgstr('test'), u'Esto es una "prueba"')
예제 #4
0
    def test_case1(self):
        """Test for newlines."""
        content = 'msgid "Add"\n' \
                  'msgstr "Ajouter\\n"\n'
        po = POFile()
        po.load_state_from_string(content)

        self.assertEqual(po.get_msgstr('Add'), u'Ajouter\n')
예제 #5
0
    def test_case2(self):
        """Test for multiple lines."""
        content = 'msgid "Hello world"\n' \
                  'msgstr ""\n' \
                  '"Hola "\n' \
                  '"mundo"\n'
        po = POFile()
        po.load_state_from_string(content)

        self.assertEqual(po.get_msgstr('Hello world'), u'Hola mundo')
예제 #6
0
    def test_case2(self):
        """Test for multiple lines."""
        content = 'msgid "Hello world"\n' \
                  'msgstr ""\n' \
                  '"Hola "\n' \
                  '"mundo"\n'
        po = POFile()
        po.load_state_from_string(content)

        self.assertEqual(po.get_msgstr('Hello world'), u'Hola mundo')
예제 #7
0
    def po_import(self, lang, data):
        """ """
        messages = self._messages

        # Load the data
        po = POFile(string=data)
        for msgid in po.get_msgids():
            if msgid:
                msgstr = po.get_msgstr(msgid) or ""
                if not messages.has_key(msgid):
                    messages[msgid] = PersistentMapping()
                messages[msgid][lang] = msgstr

        # Set the encoding (the full header should be loaded XXX)
        self.update_po_header(lang, charset=po.get_encoding())