Ejemplo n.º 1
0
def main(argv=None):
    from translate.convert import convert
    formats = {
        "oo": ("po", convertoo),
        "sdf": ("po", convertoo),
    }
    # always treat the input as an archive unless it is a directory
    archiveformats = {(None, "input"): oo.oomultifile}
    parser = convert.ArchiveConvertOptionParser(formats, usepots=True,
                                                description=__doc__,
                                                archiveformats=archiveformats)
    parser.add_option("-l", "--language", dest="targetlanguage", default=None,
                      help="set target language to extract from oo file (e.g. af-ZA)",
                      metavar="LANG")
    parser.add_option(
        "", "--source-language", dest="sourcelanguage", default=None,
        help="set source language code (default en-US)", metavar="LANG")
    parser.add_option("", "--nonrecursiveinput", dest="allowrecursiveinput",
                      default=True, action="store_false",
                      help="don't treat the input oo as a recursive store")
    parser.add_duplicates_option()
    parser.add_multifile_option()
    parser.passthrough.append("pot")
    parser.passthrough.append("sourcelanguage")
    parser.passthrough.append("targetlanguage")
    parser.verifyoptions = verifyoptions
    parser.run(argv)
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),
    ]
    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.ArchiveConvertOptionParser(
        formats,
        usetemplates=True,
        usepots=True,
        description=__doc__,
        archiveformats={"xpi": xpi.XpiFile})
    parser.add_duplicates_option()
    parser.passthrough.append("pot")
    parser.run(argv)
Ejemplo n.º 3
0
def main(argv=None):
    formats = {
        ("po", "oo"): ("oo", convertoo),
        ("xlf", "oo"): ("oo", convertoo),
        ("xliff", "oo"): ("oo", convertoo),
        ("po", "sdf"): ("sdf", convertoo),
    }
    # always treat the input as an archive unless it is a directory
    archiveformats = {(None, "output"): oo.oomultifile, (None, "template"): oo.oomultifile}
    parser = convert.ArchiveConvertOptionParser(formats, usetemplates=True, description=__doc__, archiveformats=archiveformats)
    parser.add_option("-l", "--language", dest="targetlanguage", default=None,
                      help="set target language code (e.g. af-ZA) [required]",
                      metavar="LANG")
    parser.add_option("", "--source-language", dest="sourcelanguage",
                      default=None,
                      help="set source language code (default en-US)",
                      metavar="LANG")
    parser.add_option(
        "-T", "--keeptimestamp", dest="timestamp", default=None,
        action="store_const", const=0,
        help="don't change the timestamps of the strings")
    parser.add_option("", "--nonrecursiveoutput", dest="allowrecursiveoutput",
                      default=True, action="store_false",
                      help="don't treat the output oo as a recursive store")
    parser.add_option("", "--nonrecursivetemplate",
                      dest="allowrecursivetemplate", default=True,
                      action="store_false",
                      help="don't treat the template oo as a recursive store")
    parser.add_option("", "--skipsource", dest="skip_source", default=False,
                      action="store_true",
                      help="don't output the source language, but fallback to it where needed")
    parser.add_option("", "--filteraction", dest="filteraction", default="none", metavar="ACTION",
                      help="action on pofilter failure: none (default), warn, exclude-serious, exclude-all")
    parser.add_threshold_option()
    parser.add_fuzzy_option()
    parser.add_multifile_option()
    parser.passthrough.append("sourcelanguage")
    parser.passthrough.append("targetlanguage")
    parser.passthrough.append("timestamp")
    parser.passthrough.append("skip_source")
    parser.passthrough.append("filteraction")
    parser.run(argv)