[open-ils-commits] r8067 - in trunk: . build build/i18n

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Nov 15 00:56:30 EST 2007


Author: dbs
Date: 2007-11-15 00:39:43 -0500 (Thu, 15 Nov 2007)
New Revision: 8067

Added:
   trunk/build/
   trunk/build/i18n/
   trunk/build/i18n/convert2po.py
Log:
First step towards a saner translation framework for Evergreen.
We wrap Translate Toolkit to convert DTD and property files to PO format.


Added: trunk/build/i18n/convert2po.py
===================================================================
--- trunk/build/i18n/convert2po.py	                        (rev 0)
+++ trunk/build/i18n/convert2po.py	2007-11-15 05:39:43 UTC (rev 8067)
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# -----------------------------------------------------------------------
+# Copyright (C) 2007  Laurentian University
+# Dan Scott <dscott at laurentian.ca>
+# 
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# --------------------------------------------------------------------
+#
+# Generates a complete set of PO files from DTD and JavaScript property
+# files for use in translation.
+#
+# DTD files are placed in a /dtd/ subdirectory and property files are
+# placed in a /property/ subdirectory so that we can round-trip the
+# files back into DTD and property file format once they have been
+# translated.
+#
+# Prerequisite: Translate Toolkit from http://translate.sourceforge.net/
+
+import glob
+import os.path
+from translate.convert import moz2po
+
+def convert2po(dir, extension):
+    """
+    Run moz2po on property and entity files to generate PO files.
+
+    For each property or entity file:
+        moz2po.main(["-i", "(name).ext", "-o", "(name).po"])
+    """
+    files = os.path.abspath(dir)
+    for file in glob.glob(os.path.join(files , '*.' + extension)):
+        base = os.path.basename(file)
+        sep = base.find(".")
+        root = base[:sep]
+        target = os.path.join(os.path.abspath('.'), extension);
+        if os.access(target, os.F_OK) is False:
+            os.mkdir(target)
+        moz2po.main(["-i", file, "-o", os.path.join(target, root + ".po"), "--progress", "none"])
+
+if __name__=='__main__':
+    convert2po('../../Open-ILS/web/opac/locale/en-US/', 'dtd')
+    convert2po('../../Open-ILS/xul/staff_client/chrome/locale/en-US/', 'properties')



More information about the open-ils-commits mailing list