Code to convert between different storage formats for localizations.
functions used to manipulate access keys in strings.
Helper to mix separately defined labels and accesskeys into one unit.
Populates mixedentities from the index.
Mix the given units into the given target_unit if possible.
Might return None if no match is possible.
Combine a label and and accesskey to form a label+accesskey string.
We place an accesskey marker before the accesskey in the label and this creates a string with the two combined e.g. “File” + “F” = “&File”
The case of the accesskey is preferred unless no match is found, in which case the alternate case is used.
label (unicode) – a label
accesskey (unicode char) – The accesskey
unicode or None
label+accesskey string or None if uncombineable
Extract the label and accesskey from a label+accesskey string.
The function will also try to ignore &entities; which would obviously not contain accesskeys.
string (Unicode) – A string that might contain a label with accesskey marker
accesskey_marker (Char) – The character that is used to prefix an access key
Handles converting of files between formats (used by
translate.convert
tools).
ConvertOptionParser that can handle recursing into single archive files.
archiveformats
maps extension to class. If the extension doesn’t
matter, it can be None.
If the extension is only valid for input/output/template, it can be given
as (extension, filepurpose)
.
Adds an option to say what to do with duplicate strings.
Adds an option to include / exclude fuzzy translations.
Adds an option to say how to split the po/pot files.
Adds an option to remove key value from output if it is untranslated.
Adds an option to output only stores where translation percentage exceeds the threshold.
-> (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.
Checks to see if subdir under options.output
needs to be
created, creates if neccessary.
Defines the given option, replacing an existing one of the same short name if neccessary…
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.
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.
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.
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.
Filters input formats, processing relevant switches in options.
Filters output options, processing relevant switches in options.
Write the temp outputfile to its final destination.
Returns a formatted manpage.
Returns the archiveclass for the given fileext and filepurpose.
Make a nice help string for describing formats…
Gets the absolute path to an input file.
Gets the absolute path to an output file.
Gets the absolute path to a template file.
Gets an output filename based on the input filename.
Works out which output format and processor method to use…
Get the options required to pass to the filtermethod…
Gets an output filename based on the input filename.
Returns the usage string for the given option.
Returns the usage string for the given option.
Returns whether the file option is an archive file.
Checks if this path has been excluded.
Checks if fileoption is a recursive file.
Checks if this is a valid input filename.
Makes a subdirectory (recursively if neccessary).
Creates an archive object for the given file.
Opens the input file.
Opens the output file.
Opens the template file (if required).
Opens a temporary output file.
Parses the command line options, handling implicit input/output args.
Converts a .po to a .pot where required.
Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).
Outputs a manpage for the program using the help information.
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 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.
Run an individual conversion.
Recurse through archive files and convert files.
Use a list of files, and find a common base directory for them.
Recurse through archive file / directories and return files to be converted.
Recurse through directories and convert files.
Parses the command line options and runs the conversion.
sets the usage string - if usage not given, uses getusagestring for each option.
Sets the errorlevel options.
Sets the format options using the given format dictionary.
formats (Dictionary or iterable) –
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.
creates a manpage option that allows the optionparser to generate a manpage.
Sets the -P
/--pot
option depending on input/output formats
etc.
Sets the progress options.
Sets -S
/--timestamp
option.
Splits pathname into name and ext, and removes the extsep.
pathname (string) – A file path
root, ext
tuple
Splits an inputpath into name and extension.
Splits a templatepath into name and extension.
Returns whether the given template exists…
Verifies that the options are valid (required options are present, etc).
Print a warning message incorporating ‘msg’ to stderr.
A specialized Option Parser for convertor tools…
Adds an option to say what to do with duplicate strings.
Adds an option to include / exclude fuzzy translations.
Adds an option to say how to split the po/pot files.
Adds an option to remove key value from output if it is untranslated.
Adds an option to output only stores where translation percentage exceeds the threshold.
-> (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.
Checks to see if subdir under options.output needs to be created, creates if neccessary.
Defines the given option, replacing an existing one of the same short name if neccessary…
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.
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.
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.
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.
Filters input formats, processing relevant switches in options.
Filters output options, processing relevant switches in options.
Write the temp outputfile to its final destination.
Returns a formatted manpage.
Make a nice help string for describing formats…
Gets the full path to an input file.
Gets the full path to an output file.
Gets the full path to a template file.
Gets an output filename based on the input filename.
Works out which output format and processor method to use…
Get the options required to pass to the filtermethod…
Gets an output filename based on the input filename.
Returns the usage string for the given option.
Returns the usage string for the given option.
Checks if this path has been excluded.
Checks if fileoption is a recursive file.
Checks if this is a valid input filename.
Makes a subdirectory (recursively if neccessary).
Opens the input file.
Opens the output file.
Opens the template file (if required).
Opens a temporary output file.
Parses the command line options, handling implicit input/output args.
Converts a .po to a .pot where required.
Print an extended help message, listing all options and any help text provided with them, to ‘file’ (default stdout).
Outputs a manpage for the program using the help information.
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 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.
Process an individual file.
Use a list of files, and find a common base directory for them.
Recurse through directories and return files to be processed.
Recurse through directories and process files.
Parses the command line options and runs the conversion.
sets the usage string - if usage not given, uses getusagestring for each option.
Sets the errorlevel options.
Sets the format options using the given format dictionary.
formats (Dictionary or iterable) –
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.
creates a manpage option that allows the optionparser to generate a manpage.
Sets the -P
/--pot
option depending on input/output formats
etc.
Sets the progress options.
Sets -S
/--timestamp
option.
Splits pathname into name and ext, and removes the extsep.
pathname (string) – A file path
root, ext
tuple
Splits an inputpath into name and extension.
Splits a templatepath into name and extension.
Returns whether the given template exists…
Verifies that the options are valid (required options are present, etc).
Print a warning message incorporating ‘msg’ to stderr.
An object that knows how to replace strings in files.
Actually replace the text.
Copies the input file to the output file, searching and replacing.
Copies the template file to the output file, searching and replacing.
Copies the input file to the output file.
Copies the template file to the output file.
Check if the percent of translated source words more than or equal to the given threshold.
Convert Comma-Separated Value (.csv) files to a TermBase eXchange (.tbx) glossary file.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/csv2tbx.html for examples and usage instructions
reads in inputfile using csvl10n, converts using csv2tbx, writes to outputfile.
Factory methods to convert supported input files to supported translatable files.
Convert OpenDocument (ODF) files to XLIFF localization files.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/odf2xliff.html for examples and usage instructions.
Convert an ODF package to XLIFF.
Convert an OpenOffice.org (SDF) localization file to XLIFF localization files.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/oo2po.html for examples and usage instructions.
Reads in stdin using inputstore class, converts using convertorclass, writes to stdout.
Verifies the commandline options.
Convert Gettext PO localization files to JSON files.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/json2po.html for examples and usage instructions.
Convert Gettext PO localization files to an OpenOffice.org (SDF) localization file.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/oo2po.html for examples and usage instructions.
Convert Gettext PO localisation files to .Net Resource (.resx) files.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/resx2po.html for examples and usage instructions.
Convert Gettext PO localization files to plain text (.txt) files.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/txt2po.html for examples and usage instructions.
po2txt can take a po file and generate txt.
best to give it a template file otherwise will just concat msgstrs
Convert a source file to a target file.
Convert a source file to a target file using a template file.
Source file is in source format, while target and template files use target format.
Run the converter.
Rewraps text as required.
Wrapper around converter.
Convert GNU/gettext PO files to web2py translation dictionaries (.py).
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/web2py2po.html for examples and usage instructions.
Convert XLIFF translation files to OpenDocument (ODF) files.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/odf2xliff.html for examples and usage instructions.
Create a translated ODF using an ODF template and a XLIFF file.
Write the translated ODF package.
The resulting ODF package is a copy of the template ODF package, with the translatable files replaced by their translated versions.
Convert XLIFF localization files to an OpenOffice.org (SDF) localization file.
See: http://docs.translatehouse.org/projects/translate-toolkit/en/latest/commands/oo2po.html for examples and usage instructions.