Beispiel #1
0
    def test(self):
        jinja2_env = create_jinja2_env(layouts_dir='tests/fixtures/layouts')

        with tempfile.NamedTemporaryFile() as pot_file:
            extract_translations(jinja2_env, pot_file.name)
            po_entries = polib.pofile(pot_file.name)
            
            self.assertEqual(
                str(po_entries[0]),
                '#: test.html:1\n'
                'msgid "Static"\n'
                'msgstr "Static"\n')
            
            self.assertEqual(
                str(po_entries[1]),
                '#: test.html:1 test.html:3\n'
                'msgid "sites"\n'
                'msgstr "sites"\n')
Beispiel #2
0
def extract_messages(to='translations/messages.pot'):
    """Extracts localizable strings from the templates."""
    settings.configure('settings')
    jinja2_env = create_jinja2_env()
    extract_translations(jinja2_env, to)