Beispiel #1
0
def main(argv=None):
    formats = {
        (None, "*"): ("*", convert.copytemplate),
        ("*", "*"): ("*", convert.copyinput),
        "*": ("*", convert.copyinput),
    }
    # handle formats that convert to .po files
    converters = [
        ("dtd", dtd2po.convertdtd),
        ("properties", prop2po.convertmozillaprop),
        ("it", mozfunny2prop.it2po),
        ("ini", mozfunny2prop.ini2po),
        ("inc", mozfunny2prop.inc2po),
        ("lang", mozlang2po.run_converter),
    ]
    for format, converter in converters:
        formats[(format, format)] = (format + ".po", converter)
        formats[format] = (format + ".po", converter)
    # handle search and replace
    replacer = convert.Replacer("en-US", "${locale}")
    for replaceformat in ("js", "rdf", "manifest"):
        formats[(None, replaceformat)] = (replaceformat,
                                          replacer.searchreplacetemplate)
        formats[(replaceformat, replaceformat)] = (replaceformat,
                                                   replacer.searchreplaceinput)
        formats[replaceformat] = (replaceformat, replacer.searchreplaceinput)
    parser = convert.ConvertOptionParser(formats,
                                         usetemplates=True,
                                         usepots=True,
                                         description=__doc__)
    parser.add_duplicates_option()
    parser.passthrough.append("pot")
    parser.run(argv)
Beispiel #2
0
def main(argv=None):
    # handle command line options
    formats = {("dtd.po", "dtd"): ("dtd", po2dtd.convertdtd),
               ("properties.po", "properties"): ("properties",
                                                 po2prop.convertmozillaprop),
               ("it.po", "it"): ("it", prop2mozfunny.po2it),
               ("ini.po", "ini"): ("ini", prop2mozfunny.po2ini),
               ("inc.po", "inc"): ("inc", prop2mozfunny.po2inc),
               ("lang.po", "lang"): ("lang", po2mozlang.convertlang),
               # (None, "*"): ("*", convert.copytemplate),
               ("*", "*"): ("*", convert.copyinput),
               "*": ("*", convert.copyinput)}
    # handle search and replace
    replacer = convert.Replacer("${locale}", None)
    for replaceformat in ("js", "rdf", "manifest"):
        formats[(None, replaceformat)] = (replaceformat,
                                          replacer.searchreplacetemplate)
        formats[(replaceformat, replaceformat)] = (replaceformat,
                                                   replacer.searchreplaceinput)
        formats[replaceformat] = (replaceformat, replacer.searchreplaceinput)
    parser = MozConvertOptionParser(formats, usetemplates=True, description=__doc__)
    parser.add_option("-l", "--locale", dest="locale", default=None,
        help="set output locale (required as this sets the directory names)",
        metavar="LOCALE")
    parser.add_option("", "--clonexpi", dest="clonexpi", default=None,
        help="clone xpi structure from the given xpi file")
    parser.add_fuzzy_option()
    parser.replacer = replacer
    parser.run(argv)