diff options
| author | 2013-05-30 17:41:06 -0300 | |
|---|---|---|
| committer | 2013-05-30 17:41:06 -0300 | |
| commit | 0c4dfdec5b55b6064dccc38bbfb0a7c0699c895a (patch) | |
| tree | a6707225ccc559f7edf50ddd3fdc7fc85145c921 /scripts | |
| parent | 8b14a1e5b2ca574fdd4fd2377567ec98a110d4b6 (diff) | |
Imported Upstream version 5.4.4
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/import_po.py | 29 | ||||
| -rw-r--r-- | scripts/nikola.bat | 2 |
2 files changed, 31 insertions, 0 deletions
diff --git a/scripts/import_po.py b/scripts/import_po.py new file mode 100644 index 0000000..6514391 --- /dev/null +++ b/scripts/import_po.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +"""Download translations from transifex and regenerate files.""" + +from __future__ import unicode_literals, print_function +import codecs +from glob import glob +import os + +import polib + +os.system("tx pull -a") +trans_files = glob(os.path.join('translations', 'nikola.messages', '*.po')) +for fname in trans_files: + lang = os.path.splitext(os.path.basename(fname))[0].lower() + outf = os.path.join('nikola', 'data', 'themes', 'default', + 'messages', 'messages_{0}.py'.format(lang)) + po = polib.pofile(fname) + lines = """# -*- encoding:utf-8 -*- +from __future__ import unicode_literals + +MESSAGES = {""".splitlines() + lines2 = [] + for entry in po: + lines2.append(' "{0}": "{1}",'. format(entry.msgid, entry.msgstr)) + lines.extend(sorted(lines2)) + lines.append("}\n") + print("Generating:", outf) + with codecs.open(outf, "wb+", "utf8") as outfile: + outfile.write('\n'.join(lines)) diff --git a/scripts/nikola.bat b/scripts/nikola.bat new file mode 100644 index 0000000..0aad2d4 --- /dev/null +++ b/scripts/nikola.bat @@ -0,0 +1,2 @@ +@echo off +python "%~dpn0" %*
\ No newline at end of file |
