2 # -----------------------------------------------------------------------
3 # Copyright (C) 2007 Laurentian University
4 # Dan Scott <dscott@laurentian.ca>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 # --------------------------------------------------------------------
17 # Generates a complete set of PO files from DTD and JavaScript property
18 # files for use in translation.
20 # DTD files are placed in a /dtd/ subdirectory and property files are
21 # placed in a /property/ subdirectory so that we can round-trip the
22 # files back into DTD and property file format once they have been
25 # Prerequisite: Translate Toolkit from http://translate.sourceforge.net/
29 from translate.convert import moz2po
31 def convert2po(dir, extension):
33 Run moz2po on property and entity files to generate PO files.
35 For each property or entity file:
36 moz2po.main(["-i", "(name).ext", "-o", "(name).po"])
38 files = os.path.abspath(dir)
39 for file in glob.glob(os.path.join(files , '*.' + extension)):
40 base = os.path.basename(file)
43 target = os.path.join(os.path.abspath('.'), extension);
44 if os.access(target, os.F_OK) is False:
46 moz2po.main(["-i", file, "-o", os.path.join(target, root + ".po"), "--progress", "none"])
48 if __name__=='__main__':
49 convert2po('../../Open-ILS/web/opac/locale/en-US/', 'dtd')
50 convert2po('../../Open-ILS/xul/staff_client/chrome/locale/en-US/', 'properties')