# tools

Code to perform various operations, mostly on po files.

## build_tmdb

Import units from translations files into tmdb.

## phppo2pypo

Convert PHP format .po files to Python format .po files.

`translate.tools.phppo2pypo.``convertphp2py`(inputfile, outputfile, template=None)

  Converts from PHP .po format to Python .po format

  Parameters: | inputfile – file handle of the source outputfile – file handle to write to template – unused

`translate.tools.phppo2pypo.``main`(argv=None)

  Converts PHP .po files to Python .po files.

## poclean

Produces a clean file from an unclean file (Trados/Wordfast) by stripping out the tw4win indicators.

This does not convert an RTF file to PO/XLIFF, but produces the target file with only the target text in from a text version of the RTF.

`translate.tools.poclean.``cleanfile`(thefile)

  cleans the given file

`translate.tools.poclean.``cleanunit`(unit)

  cleans the targets in the given unit

`translate.tools.poclean.``runclean`(inputfile, outputfile, templatefile)

  reads in inputfile, cleans, writes to outputfile

## pocompile

Compile XLIFF and Gettext PO localization files into Gettext MO (Machine Object) files.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/pocompile.html for examples and usage instructions.

`translate.tools.pocompile.``convertmo`(inputfile, outputfile, templatefile, includefuzzy=False)

  reads in a base class derived inputfile, converts using pocompile, writes to outputfile

## poconflicts

Conflict finder for Gettext PO localization files.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/poconflicts.html for examples and usage instructions.

class `translate.tools.poconflicts.``ConflictOptionParser`(formats, usetemplates=False, allowmissingtemplate=False, description=None)

  a specialized Option Parser for the conflict tool...

  `add_option`(Option)

    add_option(opt_str, ..., kwarg=val, ...)

  `buildconflictmap`()

    work out which strings are conflicting

  `check_values`(values : Values, args : [string])

    -> (values : Values, args : [string])

    Check that the supplied option values and leftover arguments are valid. Returns the option values and leftover arguments (possibly adjusted, possibly completely new – whatever you like). Default implementation just returns the passed-in values; subclasses may override as desired.

  `checkoutputsubdir`(options, subdir)

    Checks to see if subdir under options.output needs to be created, creates if neccessary.

  `clean`(string, options)

    returns the cleaned string that contains the text to be matched

  `define_option`(option)

    Defines the given option, replacing an existing one of the same short name if neccessary...

  `destroy`()

    Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.

  `disable_interspersed_args`()

    Set parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don’t get confused.

  `enable_interspersed_args`()

    Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.

  `error`(msg : string)

    Print a usage message incorporating ‘msg’ to stderr and exit. If you override this in a subclass, it should not return – it should either exit or raise an exception.

  `finalizetempoutputfile`(options, outputfile, fulloutputpath)

    Write the temp outputfile to its final destination.

  `flatten`(text, joinchar)

    flattens text to just be words

  `format_manpage`()

    returns a formatted manpage

  `getformathelp`(formats)

    Make a nice help string for describing formats...

  `getfullinputpath`(options, inputpath)

    Gets the absolute path to an input file.

  `getfulloutputpath`(options, outputpath)

    Gets the absolute path to an output file.

  `getfulltemplatepath`(options, templatepath)

    Gets the absolute path to a template file.

  `getoutputname`(options, inputname, outputformat)

    Gets an output filename based on the input filename.

  `getoutputoptions`(options, inputpath, templatepath)

    Works out which output format and processor method to use...

  `getpassthroughoptions`(options)

    Get the options required to pass to the filtermethod...

  `gettemplatename`(options, inputname)

    Gets an output filename based on the input filename.

  `getusageman`(option)

    returns the usage string for the given option

  `getusagestring`(option)

    returns the usage string for the given option

  `isexcluded`(options, inputpath)

    Checks if this path has been excluded.

  `isrecursive`(fileoption, filepurpose='input')

    Checks if fileoption is a recursive file.

  `isvalidinputname`(inputname)

    Checks if this is a valid input filename.

  `mkdir`(parent, subdir)

    Makes a subdirectory (recursively if neccessary).

  `openinputfile`(options, fullinputpath)

    Opens the input file.

  `openoutputfile`(options, fulloutputpath)

    Opens the output file.

  `opentemplatefile`(options, fulltemplatepath)

    Opens the template file (if required).

  `opentempoutputfile`(options, fulloutputpath)

    Opens a temporary output file.

  `outputconflicts`(options)

    saves the result of the conflict match

  `parse_args`(args=None, values=None)

    parses the command line options, handling implicit input/output args

  `print_help`(file : file = stdout)

    Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).

  `print_manpage`(file=None)

    outputs a manpage for the program using the help information

  `print_usage`(file : file = stdout)

    Print the usage message for the current program (self.usage) to ‘file’ (default stdout). Any occurrence of the string “%prog” in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.

  `print_version`(file : file = stdout)

    Print the version message for this program (self.version) to ‘file’ (default stdout). As with print_usage(), any occurrence of “%prog” in self.version is replaced by the current program’s name. Does nothing if self.version is empty or undefined.

  `processfile`(fileprocessor, options, fullinputpath)

    process an individual file

  `recurseinputfilelist`(options)

    Use a list of files, and find a common base directory for them.

  `recurseinputfiles`(options)

    Recurse through directories and return files to be processed.

  `recursiveprocess`(options)

    recurse through directories and process files

  `run`()

    Parses the arguments, and runs recursiveprocess with the resulting options...

  `set_usage`(usage=None)

    sets the usage string - if usage not given, uses getusagestring for each option

  `seterrorleveloptions`()

    Sets the errorlevel options.

  `setformats`(formats, usetemplates)

    Sets the format options using the given format dictionary.

    Parameters: | formats (Dictionary) – The dictionary keys should be: Single strings (or 1-tuples) containing an input format (if not usetemplates) Tuples containing an input format and template format (if usetemplates) Formats can be None to indicate what to do with standard input The dictionary values should be tuples of outputformat (string) and processor method.

  `setmanpageoption`()

    creates a manpage option that allows the optionparser to generate a manpage

  `setprogressoptions`()

    Sets the progress options.

  `splitext`(pathname)

    Splits pathname into name and ext, and removes the extsep.

    Parameters: | pathname (string) – A file path
    Returns: | root, ext
    Return type: | tuple

  `splitinputext`(inputpath)

    Splits an inputpath into name and extension.

  `splittemplateext`(templatepath)

    Splits a templatepath into name and extension.

  `templateexists`(options, templatepath)

    Returns whether the given template exists...

  `warning`(msg, options=None, exc_info=None)

    Print a warning message incorporating ‘msg’ to stderr and exit.

## pocount

Count strings and words for supported localization files.

These include: XLIFF, TMX, Gettex PO and MO, Qt .ts and .qm, Wordfast TM, etc

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/pocount.html for examples and usage instructions.

class `translate.tools.pocount.``ConsoleColor`

  Class to implement color mode.

`translate.tools.pocount.``calcstats_old`(filename)

  This is the previous implementation of calcstats() and is left for comparison and debuging purposes.

`translate.tools.pocount.``summarize`(title, stats, style=0, indent=8, incomplete_only=False)

  Print summary for a .po file in specified format.

  Parameters: | title – name of .po file stats – array with translation statistics for the file specified indent – indentation of the 2nd column (length of longest filename) incomplete_only (Boolean) – omit fully translated files
  Return type: | Boolean
  Returns: | 1 if counting incomplete files (incomplete_only=True) and the file is completely translated, 0 otherwise

## podebug

Insert debug messages into XLIFF and Gettext PO localization files.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/podebug.html for examples and usage instructions.

`translate.tools.podebug.``convertpo`(inputfile, outputfile, templatefile, format=None, rewritestyle=None, ignoreoption=None, preserveplaceholders=None)

  Reads in inputfile, changes it to have debug strings, writes to outputfile.

## pogrep

Grep XLIFF, Gettext PO and TMX localization files.

Matches are output to snippet files of the same type which can then be reviewed and later merged using pomerge.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/pogrep.html for examples and usage instructions.

class `translate.tools.pogrep.``GrepMatch`(unit, part='target', part_n=0, start=0, end=0)

  Just a small data structure that represents a search match.

class `translate.tools.pogrep.``GrepOptionParser`(formats, usetemplates=False, allowmissingtemplate=False, description=None)

  a specialized Option Parser for the grep tool...

  `add_option`(Option)

    add_option(opt_str, ..., kwarg=val, ...)

  `check_values`(values : Values, args : [string])

    -> (values : Values, args : [string])

    Check that the supplied option values and leftover arguments are valid. Returns the option values and leftover arguments (possibly adjusted, possibly completely new – whatever you like). Default implementation just returns the passed-in values; subclasses may override as desired.

  `checkoutputsubdir`(options, subdir)

    Checks to see if subdir under options.output needs to be created, creates if neccessary.

  `define_option`(option)

    Defines the given option, replacing an existing one of the same short name if neccessary...

  `destroy`()

    Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.

  `disable_interspersed_args`()

    Set parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don’t get confused.

  `enable_interspersed_args`()

    Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.

  `error`(msg : string)

    Print a usage message incorporating ‘msg’ to stderr and exit. If you override this in a subclass, it should not return – it should either exit or raise an exception.

  `finalizetempoutputfile`(options, outputfile, fulloutputpath)

    Write the temp outputfile to its final destination.

  `format_manpage`()

    returns a formatted manpage

  `getformathelp`(formats)

    Make a nice help string for describing formats...

  `getfullinputpath`(options, inputpath)

    Gets the absolute path to an input file.

  `getfulloutputpath`(options, outputpath)

    Gets the absolute path to an output file.

  `getfulltemplatepath`(options, templatepath)

    Gets the absolute path to a template file.

  `getoutputname`(options, inputname, outputformat)

    Gets an output filename based on the input filename.

  `getoutputoptions`(options, inputpath, templatepath)

    Works out which output format and processor method to use...

  `getpassthroughoptions`(options)

    Get the options required to pass to the filtermethod...

  `gettemplatename`(options, inputname)

    Gets an output filename based on the input filename.

  `getusageman`(option)

    returns the usage string for the given option

  `getusagestring`(option)

    returns the usage string for the given option

  `isexcluded`(options, inputpath)

    Checks if this path has been excluded.

  `isrecursive`(fileoption, filepurpose='input')

    Checks if fileoption is a recursive file.

  `isvalidinputname`(inputname)

    Checks if this is a valid input filename.

  `mkdir`(parent, subdir)

    Makes a subdirectory (recursively if neccessary).

  `openinputfile`(options, fullinputpath)

    Opens the input file.

  `openoutputfile`(options, fulloutputpath)

    Opens the output file.

  `opentemplatefile`(options, fulltemplatepath)

    Opens the template file (if required).

  `opentempoutputfile`(options, fulloutputpath)

    Opens a temporary output file.

  `parse_args`(args=None, values=None)

    parses the command line options, handling implicit input/output args

  `print_help`(file : file = stdout)

    Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).

  `print_manpage`(file=None)

    outputs a manpage for the program using the help information

  `print_usage`(file : file = stdout)

    Print the usage message for the current program (self.usage) to ‘file’ (default stdout). Any occurrence of the string “%prog” in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.

  `print_version`(file : file = stdout)

    Print the version message for this program (self.version) to ‘file’ (default stdout). As with print_usage(), any occurrence of “%prog” in self.version is replaced by the current program’s name. Does nothing if self.version is empty or undefined.

  `processfile`(fileprocessor, options, fullinputpath, fulloutputpath, fulltemplatepath)

    Process an individual file.

  `recurseinputfilelist`(options)

    Use a list of files, and find a common base directory for them.

  `recurseinputfiles`(options)

    Recurse through directories and return files to be processed.

  `recursiveprocess`(options)

    Recurse through directories and process files.

  `run`()

    parses the arguments, and runs recursiveprocess with the resulting options

  `set_usage`(usage=None)

    sets the usage string - if usage not given, uses getusagestring for each option

  `seterrorleveloptions`()

    Sets the errorlevel options.

  `setformats`(formats, usetemplates)

    Sets the format options using the given format dictionary.

    Parameters: | formats (Dictionary) – The dictionary keys should be: Single strings (or 1-tuples) containing an input format (if not usetemplates) Tuples containing an input format and template format (if usetemplates) Formats can be None to indicate what to do with standard input The dictionary values should be tuples of outputformat (string) and processor method.

  `setmanpageoption`()

    creates a manpage option that allows the optionparser to generate a manpage

  `setprogressoptions`()

    Sets the progress options.

  `splitext`(pathname)

    Splits pathname into name and ext, and removes the extsep.

    Parameters: | pathname (string) – A file path
    Returns: | root, ext
    Return type: | tuple

  `splitinputext`(inputpath)

    Splits an inputpath into name and extension.

  `splittemplateext`(templatepath)

    Splits a templatepath into name and extension.

  `templateexists`(options, templatepath)

    Returns whether the given template exists...

  `warning`(msg, options=None, exc_info=None)

    Print a warning message incorporating ‘msg’ to stderr and exit.

`translate.tools.pogrep.``find_matches`(unit, part, strings, re_search)

  Return the GrepFilter objects where re_search matches in strings.

`translate.tools.pogrep.``real_index`(string, nfc_index)

  Calculate the real index in the unnormalized string that corresponds to the index nfc_index in the normalized string.

`translate.tools.pogrep.``rungrep`(inputfile, outputfile, templatefile, checkfilter)

  reads in inputfile, filters using checkfilter, writes to outputfile

## pomerge

Merges XLIFF and Gettext PO localization files.

Snippet file produced by e.g. pogrep and updated by a translator can be merged back into the original files.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/pomerge.html for examples and usage instructions.

`translate.tools.pomerge.``mergestores`(store1, store2, mergeblanks, mergefuzzy, mergecomments)

  Take any new translations in store2 and write them into store1.

`translate.tools.pomerge.``str2bool`(option)

  Convert a string value to boolean

  Parameters: | option (String) – yes, true, 1, no, false, 0
  Return type: | Boolean

## porestructure

Restructure Gettxt PO files produced by poconflicts into the original directory tree for merging using pomerge.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/pomerge.html for examples and usage instructions.

class `translate.tools.porestructure.``SplitOptionParser`(formats, usetemplates=False, allowmissingtemplate=False, description=None)

  a specialized Option Parser for posplit

  `add_option`(Option)

    add_option(opt_str, ..., kwarg=val, ...)

  `check_values`(values : Values, args : [string])

    -> (values : Values, args : [string])

    Check that the supplied option values and leftover arguments are valid. Returns the option values and leftover arguments (possibly adjusted, possibly completely new – whatever you like). Default implementation just returns the passed-in values; subclasses may override as desired.

  `checkoutputsubdir`(options, subdir)

    Checks to see if subdir under options.output needs to be created, creates if neccessary.

  `define_option`(option)

    Defines the given option, replacing an existing one of the same short name if neccessary...

  `destroy`()

    Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.

  `disable_interspersed_args`()

    Set parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don’t get confused.

  `enable_interspersed_args`()

    Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.

  `error`(msg : string)

    Print a usage message incorporating ‘msg’ to stderr and exit. If you override this in a subclass, it should not return – it should either exit or raise an exception.

  `finalizetempoutputfile`(options, outputfile, fulloutputpath)

    Write the temp outputfile to its final destination.

  `format_manpage`()

    returns a formatted manpage

  `getformathelp`(formats)

    Make a nice help string for describing formats...

  `getfullinputpath`(options, inputpath)

    Gets the absolute path to an input file.

  `getfulloutputpath`(options, outputpath)

    Gets the absolute path to an output file.

  `getfulltemplatepath`(options, templatepath)

    Gets the absolute path to a template file.

  `getoutputname`(options, inputname, outputformat)

    Gets an output filename based on the input filename.

  `getoutputoptions`(options, inputpath, templatepath)

    Works out which output format and processor method to use...

  `getpassthroughoptions`(options)

    Get the options required to pass to the filtermethod...

  `gettemplatename`(options, inputname)

    Gets an output filename based on the input filename.

  `getusageman`(option)

    returns the usage string for the given option

  `getusagestring`(option)

    returns the usage string for the given option

  `isexcluded`(options, inputpath)

    Checks if this path has been excluded.

  `isrecursive`(fileoption, filepurpose='input')

    Checks if fileoption is a recursive file.

  `isvalidinputname`(inputname)

    Checks if this is a valid input filename.

  `mkdir`(parent, subdir)

    Makes a subdirectory (recursively if neccessary).

  `openinputfile`(options, fullinputpath)

    Opens the input file.

  `openoutputfile`(options, fulloutputpath)

    Opens the output file.

  `opentemplatefile`(options, fulltemplatepath)

    Opens the template file (if required).

  `opentempoutputfile`(options, fulloutputpath)

    Opens a temporary output file.

  `parse_args`(args=None, values=None)

    parses the command line options, handling implicit input/output args

  `print_help`(file : file = stdout)

    Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).

  `print_manpage`(file=None)

    outputs a manpage for the program using the help information

  `print_usage`(file : file = stdout)

    Print the usage message for the current program (self.usage) to ‘file’ (default stdout). Any occurrence of the string “%prog” in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.

  `print_version`(file : file = stdout)

    Print the version message for this program (self.version) to ‘file’ (default stdout). As with print_usage(), any occurrence of “%prog” in self.version is replaced by the current program’s name. Does nothing if self.version is empty or undefined.

  `processfile`(options, fullinputpath)

    process an individual file

  `recurseinputfilelist`(options)

    Use a list of files, and find a common base directory for them.

  `recurseinputfiles`(options)

    Recurse through directories and return files to be processed.

  `recursiveprocess`(options)

    recurse through directories and process files

  `run`()

    Parses the arguments, and runs recursiveprocess with the resulting options...

  `set_usage`(usage=None)

    sets the usage string - if usage not given, uses getusagestring for each option

  `seterrorleveloptions`()

    Sets the errorlevel options.

  `setformats`(formats, usetemplates)

    Sets the format options using the given format dictionary.

    Parameters: | formats (Dictionary) – The dictionary keys should be: Single strings (or 1-tuples) containing an input format (if not usetemplates) Tuples containing an input format and template format (if usetemplates) Formats can be None to indicate what to do with standard input The dictionary values should be tuples of outputformat (string) and processor method.

  `setmanpageoption`()

    creates a manpage option that allows the optionparser to generate a manpage

  `setprogressoptions`()

    Sets the progress options.

  `splitext`(pathname)

    Splits pathname into name and ext, and removes the extsep.

    Parameters: | pathname (string) – A file path
    Returns: | root, ext
    Return type: | tuple

  `splitinputext`(inputpath)

    Splits an inputpath into name and extension.

  `splittemplateext`(templatepath)

    Splits a templatepath into name and extension.

  `templateexists`(options, templatepath)

    Returns whether the given template exists...

  `warning`(msg, options=None, exc_info=None)

    Print a warning message incorporating ‘msg’ to stderr and exit.

## posegment

Segment Gettext PO, XLIFF and TMX localization files at the sentence level.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/posegment.html for examples and usage instructions.

`translate.tools.posegment.``segmentfile`(inputfile, outputfile, templatefile, sourcelanguage='en', targetlanguage=None, stripspaces=True, onlyaligned=False)

  reads in inputfile, segments it then, writes to outputfile

## poswap

Builds a new translation file with the target of the input language as source language.

Note

Ensure that the two po files correspond 100% to the same pot file before using this.

To translate Kurdish (ku) through French:

    poswap -i fr/ -t ku -o fr-ku

To convert the fr-ku files back to en-ku:

    poswap --reverse -i fr/ -t fr-ku -o en-ku

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/poswap.html for examples and usage instructions.

`translate.tools.poswap.``convertpo`(inputpofile, outputpotfile, template, reverse=False)

  reads in inputpofile, removes the header, writes to outputpotfile.

`translate.tools.poswap.``swapdir`(store)

  Swap the source and target of each unit.

## poterminology

Create a terminology file by reading a set of .po or .pot files to produce a pootle-terminology.pot.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/poterminology.html for examples and usage instructions.

class `translate.tools.poterminology.``TerminologyOptionParser`(formats, usetemplates=False, allowmissingtemplate=False, description=None)

  a specialized Option Parser for the terminology tool...

  `add_option`(Option)

    add_option(opt_str, ..., kwarg=val, ...)

  `check_values`(values : Values, args : [string])

    -> (values : Values, args : [string])

    Check that the supplied option values and leftover arguments are valid. Returns the option values and leftover arguments (possibly adjusted, possibly completely new – whatever you like). Default implementation just returns the passed-in values; subclasses may override as desired.

  `checkoutputsubdir`(options, subdir)

    Checks to see if subdir under options.output needs to be created, creates if neccessary.

  `define_option`(option)

    Defines the given option, replacing an existing one of the same short name if neccessary...

  `destroy`()

    Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.

  `disable_interspersed_args`()

    Set parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don’t get confused.

  `enable_interspersed_args`()

    Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.

  `error`(msg : string)

    Print a usage message incorporating ‘msg’ to stderr and exit. If you override this in a subclass, it should not return – it should either exit or raise an exception.

  `finalizetempoutputfile`(options, outputfile, fulloutputpath)

    Write the temp outputfile to its final destination.

  `format_manpage`()

    returns a formatted manpage

  `getformathelp`(formats)

    Make a nice help string for describing formats...

  `getfullinputpath`(options, inputpath)

    Gets the absolute path to an input file.

  `getfulloutputpath`(options, outputpath)

    Gets the absolute path to an output file.

  `getfulltemplatepath`(options, templatepath)

    Gets the absolute path to a template file.

  `getoutputname`(options, inputname, outputformat)

    Gets an output filename based on the input filename.

  `getoutputoptions`(options, inputpath, templatepath)

    Works out which output format and processor method to use...

  `getpassthroughoptions`(options)

    Get the options required to pass to the filtermethod...

  `gettemplatename`(options, inputname)

    Gets an output filename based on the input filename.

  `getusageman`(option)

    returns the usage string for the given option

  `getusagestring`(option)

    returns the usage string for the given option

  `isexcluded`(options, inputpath)

    Checks if this path has been excluded.

  `isrecursive`(fileoption, filepurpose='input')

    Checks if fileoption is a recursive file.

  `isvalidinputname`(inputname)

    Checks if this is a valid input filename.

  `mkdir`(parent, subdir)

    Makes a subdirectory (recursively if neccessary).

  `openinputfile`(options, fullinputpath)

    Opens the input file.

  `openoutputfile`(options, fulloutputpath)

    Opens the output file.

  `opentemplatefile`(options, fulltemplatepath)

    Opens the template file (if required).

  `opentempoutputfile`(options, fulloutputpath)

    Opens a temporary output file.

  `outputterminology`(options)

    saves the generated terminology glossary

  `parse_args`(args=None, values=None)

    parses the command line options, handling implicit input/output args

  `print_help`(file : file = stdout)

    Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).

  `print_manpage`(file=None)

    outputs a manpage for the program using the help information

  `print_usage`(file : file = stdout)

    Print the usage message for the current program (self.usage) to ‘file’ (default stdout). Any occurrence of the string “%prog” in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.

  `print_version`(file : file = stdout)

    Print the version message for this program (self.version) to ‘file’ (default stdout). As with print_usage(), any occurrence of “%prog” in self.version is replaced by the current program’s name. Does nothing if self.version is empty or undefined.

  `processfile`(fileprocessor, options, fullinputpath)

    process an individual file

  `recurseinputfilelist`(options)

    Use a list of files, and find a common base directory for them.

  `recurseinputfiles`(options)

    Recurse through directories and return files to be processed.

  `recursiveprocess`(options)

    recurse through directories and process files

  `run`()

    parses the arguments, and runs recursiveprocess with the resulting options

  `set_usage`(usage=None)

    sets the usage string - if usage not given, uses getusagestring for each option

  `seterrorleveloptions`()

    Sets the errorlevel options.

  `setformats`(formats, usetemplates)

    Sets the format options using the given format dictionary.

    Parameters: | formats (Dictionary) – The dictionary keys should be: Single strings (or 1-tuples) containing an input format (if not usetemplates) Tuples containing an input format and template format (if usetemplates) Formats can be None to indicate what to do with standard input The dictionary values should be tuples of outputformat (string) and processor method.

  `setmanpageoption`()

    creates a manpage option that allows the optionparser to generate a manpage

  `setprogressoptions`()

    Sets the progress options.

  `splitext`(pathname)

    Splits pathname into name and ext, and removes the extsep.

    Parameters: | pathname (string) – A file path
    Returns: | root, ext
    Return type: | tuple

  `splitinputext`(inputpath)

    Splits an inputpath into name and extension.

  `splittemplateext`(templatepath)

    Splits a templatepath into name and extension.

  `templateexists`(options, templatepath)

    Returns whether the given template exists...

  `warning`(msg, options=None, exc_info=None)

    Print a warning message incorporating ‘msg’ to stderr and exit.

## pretranslate

Fill localization files with suggested translations based on translation memory and existing translations.

See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/pretranslate.html for examples and usage instructions.

`translate.tools.pretranslate.``match_fuzzy`(input_unit, matchers)

  Return a fuzzy match from a queue of matchers.

`translate.tools.pretranslate.``match_source`(input_unit, template_store)

  Returns a matching unit from a template. matching based on unit id

`translate.tools.pretranslate.``match_template_id`(input_unit, template_store)

  Returns a matching unit from a template. matching based on unit id

`translate.tools.pretranslate.``match_template_location`(input_unit, template_store)

  Returns a matching unit from a template. matching based on locations

`translate.tools.pretranslate.``memory`(tmfiles, max_candidates=1, min_similarity=75, max_length=1000)

  Returns the TM store to use. Only initialises on first call.

`translate.tools.pretranslate.``pretranslate_file`(input_file, output_file, template_file, tm=None, min_similarity=75, fuzzymatching=True)

  Pretranslate any factory supported file with old translations and translation memory.

`translate.tools.pretranslate.``pretranslate_store`(input_store, template_store, tm=None, min_similarity=75, fuzzymatching=True)

  Do the actual pretranslation of a whole store.

`translate.tools.pretranslate.``pretranslate_unit`(input_unit, template_store, matchers=None, mark_reused=False, merge_on='id')

  Pretranslate a unit or return unchanged if no translation was found.

  Parameters: | input_unit – Unit that will be pretranslated. template_store – Fill input unit with units matching in this store. matchers – List of fuzzy `matcher` objects. mark_reused – Whether to mark old translations as reused or not. merge_on – Where will the merge matching happen on.

## pydiff

diff tool like GNU diff, but lets you have special options that are useful in dealing with PO files

class `translate.tools.pydiff.``DirDiffer`(fromdir, todir, options)

  generates diffs between directories

  `isexcluded`(difffile)

    checks if the given filename has been excluded from the diff

  `writediff`(outfile)

    writes the actual diff to the given file

class `translate.tools.pydiff.``FileDiffer`(fromfile, tofile, options)

  generates diffs between files

  `get_from_lines`(group)

    returns the lines referred to by group, from the fromfile

  `get_to_lines`(group)

    returns the lines referred to by group, from the tofile

  `unified_diff`(group)

    takes the group of opcodes and generates a unified diff line by line

  `writediff`(outfile)

    writes the actual diff to the given file

`translate.tools.pydiff.``main`()

  main program for pydiff

## pypo2phppo

Convert Python format .po files to PHP format .po files.

`translate.tools.pypo2phppo.``convertpy2php`(inputfile, outputfile, template=None)

  Converts from Python .po to PHP .po

  Parameters: | inputfile – file handle of the source outputfile – file handle to write to template – unused

`translate.tools.pypo2phppo.``main`(argv=None)

  Converts from Python .po to PHP .po