From: dbs Date: Thu, 15 Nov 2007 05:39:43 +0000 (+0000) Subject: First step towards a saner translation framework for Evergreen. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1508006c5d9208056983ef31cfb1c6ef2b4786b7;p=Evergreen.git First step towards a saner translation framework for Evergreen. We wrap Translate Toolkit to convert DTD and property files to PO format. git-svn-id: svn://svn.open-ils.org/ILS/trunk@8067 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/build/i18n/convert2po.py b/build/i18n/convert2po.py new file mode 100644 index 0000000000..f6f21724f8 --- /dev/null +++ b/build/i18n/convert2po.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# ----------------------------------------------------------------------- +# Copyright (C) 2007 Laurentian University +# Dan Scott +# +# 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')