small improvements of the version control systems handling:
[translate_toolkit.git] / convert / moz2po.py
blobbde5d06fa0032f99f6ce63e12d4d31530aa37f6e
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright 2004-2006 Zuza Software Foundation
5 #
6 # This file is part of translate.
8 # translate is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # translate is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with translate; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 """convert Mozilla .dtd and .properties files to Gettext PO localization files
24 See: http://translate.sourceforge.net/wiki/toolkit/moz2po for examples and
25 usage instructions
26 """
28 from translate.convert import dtd2po
29 from translate.convert import prop2po
30 from translate.convert import html2po
31 from translate.convert import mozfunny2prop
32 from translate.storage import xpi
33 from translate.convert import convert
35 def main(argv=None):
36 formats = {(None, "*"): ("*", convert.copytemplate),
37 ("*", "*"): ("*", convert.copyinput),
38 "*": ("*", convert.copyinput)}
39 # handle formats that convert to .po files
40 converters = [("dtd", dtd2po.convertdtd), ("properties", prop2po.convertprop), ("xhtml", html2po.converthtml), ("html", html2po.converthtml),
41 ("it", mozfunny2prop.it2po), ("ini", mozfunny2prop.ini2po), ("inc", mozfunny2prop.inc2po)]
42 for format, converter in converters:
43 formats[(format, format)] = (format + ".po", converter)
44 formats[format] = (format + ".po", converter)
45 # handle search and replace
46 replacer = convert.Replacer("en-US", "${locale}")
47 for replaceformat in ("js", "rdf", "manifest"):
48 formats[(None, replaceformat)] = (replaceformat, replacer.searchreplacetemplate)
49 formats[(replaceformat, replaceformat)] = (replaceformat, replacer.searchreplaceinput)
50 formats[replaceformat] = (replaceformat, replacer.searchreplaceinput)
51 parser = convert.ArchiveConvertOptionParser(formats, usetemplates=True, usepots=True, description=__doc__, archiveformats={"xpi": xpi.XpiFile})
52 parser.add_duplicates_option()
53 parser.passthrough.append("pot")
54 parser.run(argv)
57 if __name__ == '__main__':
58 main()