[dev-gnome-web/wip/fredp/i18n: 1/2] Add i18n commands to manage.py



commit 19ffc97a0033762ae48e571590ffc26f35895051
Author: Frédéric Péters <fpeters 0d be>
Date:   Thu Jan 28 12:49:28 2016 +0100

    Add i18n commands to manage.py

 .gitignore |    2 ++
 manage.py  |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index aedd2ea..4ddb004 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,5 @@ __pycache__
 .cache
 .coverage*
 client/vendor/
+messages.pot
+messages.mo
diff --git a/manage.py b/manage.py
index e3251be..c30d363 100755
--- a/manage.py
+++ b/manage.py
@@ -4,6 +4,7 @@
 This is an application management application that allows to run the server.
 """
 
+import os
 from os import environ
 from subprocess import Popen, call
 from sys import executable
@@ -58,5 +59,24 @@ def docs():
     return call(['make', '-C', 'docs', 'html'])
 
 
+ manager command
+def extract_translations():
+    call(['pybabel', 'extract', '-F', 'babel.cfg', '-o', 'messages.pot', '.'])
+    for language in app.config['LANGUAGES']:
+        if language == 'en':
+            continue
+        if os.path.exists(os.path.join('server', 'translations', language)):
+            call(['pybabel', 'update', '-i', 'messages.pot', '-d',
+                  'server/translations', '-l', language])
+        else:
+            call(['pybabel', 'init', '-i', 'messages.pot', '-d',
+                  'server/translations', '-l', language])
+
+
+ manager command
+def compile_translations():
+    return call(['pybabel', 'compile', '-d', 'server/translations/'])
+
+
 if __name__ == '__main__':
     manager.run()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]