[cc-commits] [SCM] Wrapper egg for the i18n checkout (branch master) updated. d130c73c3d0b9d49fa1be6d2070b5e52f3d29f12
git version control
git at a7.creativecommons.org
Tue Mar 2 18:43:28 EST 2010
The branch, master has been updated
via d130c73c3d0b9d49fa1be6d2070b5e52f3d29f12 (commit)
from 800c0d861a122c81a05ec927dae50f54bec776a3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d130c73c3d0b9d49fa1be6d2070b5e52f3d29f12
Author: Christopher Allan Webber <cwebber at dustycloud.org>
Date: Tue Mar 2 17:43:28 2010 -0600
compile_mo script, compiles all the .mo files and puts them in cc.i18npkg/locales
-----------------------------------------------------------------------
Summary of changes (followed by patch):
cc/i18npkg/compile_mo.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
setup.py | 6 +++++-
2 files changed, 49 insertions(+), 1 deletions(-)
create mode 100644 cc/i18npkg/compile_mo.py
diff --git a/cc/i18npkg/compile_mo.py b/cc/i18npkg/compile_mo.py
new file mode 100644
index 0000000..4ec1dc7
--- /dev/null
+++ b/cc/i18npkg/compile_mo.py
@@ -0,0 +1,44 @@
+"""
+Compile .po files into .mo files in the cc
+"""
+
+import os
+import pkg_resources
+from pythongettext.msgfmt import Msgfmt
+
+
+I18N_PATH = pkg_resources.resource_filename(
+ 'cc.i18npkg', 'i18n/i18n')
+MO_FILES_BASE = pkg_resources.resource_filename(
+ 'cc.i18npkg', 'locales')
+
+
+def compile_mo_files():
+ for catalog in os.listdir(I18N_PATH):
+ catalog_path = os.path.join(I18N_PATH, catalog)
+
+ po_path = os.path.join(catalog_path, 'cc_org.po')
+
+ if not os.path.isdir(catalog_path) or not os.path.exists(po_path):
+ continue
+
+ if not os.path.exists(os.path.join(MO_FILES_BASE, catalog)):
+ os.mkdir(os.path.join(MO_FILES_BASE, catalog))
+ if not os.path.exists(os.path.join(
+ MO_FILES_BASE, catalog, 'LC_MESSAGES')):
+ os.mkdir(os.path.join(
+ MO_FILES_BASE, catalog, 'LC_MESSAGES'))
+
+ mo_path = os.path.join(
+ MO_FILES_BASE, catalog, 'LC_MESSAGES', 'cc_org.mo')
+
+ # TODO: only do this if po_mtime > mo_mtime maybe, see
+ # zope.i18n.compile
+ mo_data = Msgfmt(po_path, 'cc_org').getAsFile()
+ fd = open(mo_path, 'wb')
+ fd.write(mo_data.read())
+ fd.close()
+
+
+if __name__ == '__main__':
+ compile_mo_files()
diff --git a/setup.py b/setup.py
index a596073..cdc87b6 100644
--- a/setup.py
+++ b/setup.py
@@ -43,4 +43,8 @@ setup(
license = 'MIT',
url = 'http://creativecommons.org',
zip_safe = False,
- )
+
+ entry_points = """
+ [console_scripts]
+ compile_mo = cc.i18npkg.compile_mo:compile_mo_files
+ """)
hooks/post-receive
--
Wrapper egg for the i18n checkout
More information about the cc-commits
mailing list