convert

Code to convert between different storage formats for localizations.

acesskey

functions used to manipulate access keys in strings

class translate.convert.accesskey.UnitMixer(labelsuffixes, accesskeysuffixes)

Helper to mix separately defined labels and accesskeys into one unit.

match_entities(index)

Populates mixedentities from the index.

mix_units(label_unit, accesskey_unit, target_unit)

Mix the given units into the given target_unit if possible.

Might return None if no match is possible.

translate.convert.accesskey.combine(label, accesskey, accesskey_marker=u'&')

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.

Parameters:
  • label (unicode) – a label
  • accesskey (unicode char) – The accesskey
Return type:

unicode or None

Returns:

label+accesskey string or None if uncombineable

translate.convert.accesskey.extract(string, accesskey_marker=u'&')

Extract the label and accesskey from a label+accesskey string

The function will also try to ignore &entities; which would obviously not contain accesskeys.

Parameters:
  • 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

convert

Handles converting of files between formats (used by translate.convert tools).

class translate.convert.convert.ArchiveConvertOptionParser(formats, usetemplates=False, usepots=False, description=None, archiveformats=None)

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).

add_duplicates_option(default='msgctxt')

Adds an option to say what to do with duplicate strings.

add_fuzzy_option(default=False)

Adds an option to include / exclude fuzzy translations.

add_multifile_option(default='single')

Adds an option to say how to split the po/pot files.

add_option(Option)

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

add_remove_untranslated_option(default=False)

Adds an option to remove key value from output if it is untranslated.

add_threshold_option(default=None)

Adds an option to output only stores where translation percentage exceeds the threshold.

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.

filterinputformats(options)

Filters input formats, processing relevant switches in options.

filteroutputoptions(options)

Filters output options, processing relevant switches in options.

finalizetempoutputfile(options, outputfile, fulloutputpath)

Write the temp outputfile to its final destination.

format_manpage()

returns a formatted manpage

getarchiveclass(fileext, filepurpose, isdir=False)

Returns the archiveclass for the given fileext and filepurpose

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

isarchive(fileoption, filepurpose='input')

Returns whether the file option is an archive file.

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).

openarchive(archivefilename, filepurpose, **kwargs)

Creates an archive object for the given file.

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.

potifyformat(fileformat)

Converts a .po to a .pot where required.

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)

Run an invidividual conversion.

recursearchivefiles(options)

Recurse through archive files and convert files.

recurseinputfilelist(options)

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

recurseinputfiles(options)

Recurse through archive file / directories and return files to be converted.

recursiveprocess(options)

Recurse through directories and convert files.

run(argv=None)

Parses the command line options and runs the conversion.

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

setpotoption()

Sets the -P/--pot option depending on input/output formats etc.

setprogressoptions()

Sets the progress options.

settimestampoption()

Sets -S/--timestamp option.

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…

verifyoptions(options)

Verifies that the options are valid (required options are present, etc).

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

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

class translate.convert.convert.ConvertOptionParser(formats, usetemplates=False, usepots=False, allowmissingtemplate=False, description=None)

A specialized Option Parser for convertor tools…

add_duplicates_option(default='msgctxt')

Adds an option to say what to do with duplicate strings.

add_fuzzy_option(default=False)

Adds an option to include / exclude fuzzy translations.

add_multifile_option(default='single')

Adds an option to say how to split the po/pot files.

add_option(Option)

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

add_remove_untranslated_option(default=False)

Adds an option to remove key value from output if it is untranslated.

add_threshold_option(default=None)

Adds an option to output only stores where translation percentage exceeds the threshold.

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.

filterinputformats(options)

Filters input formats, processing relevant switches in options.

filteroutputoptions(options)

Filters output options, processing relevant switches in options.

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.

potifyformat(fileformat)

Converts a .po to a .pot where required.

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(argv=None)

Parses the command line options and runs the conversion.

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

setpotoption()

Sets the -P/--pot option depending on input/output formats etc.

setprogressoptions()

Sets the progress options.

settimestampoption()

Sets -S/--timestamp option.

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…

verifyoptions(options)

Verifies that the options are valid (required options are present, etc).

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

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

class translate.convert.convert.Replacer(searchstring, replacestring)

An object that knows how to replace strings in files.

doreplace(text)

actually replace the text

searchreplaceinput(inputfile, outputfile, templatefile, **kwargs)

copies the input file to the output file, searching and replacing

searchreplacetemplate(inputfile, outputfile, templatefile, **kwargs)

Copies the template file to the output file, searching and replacing.

translate.convert.convert.copyinput(inputfile, outputfile, templatefile, **kwargs)

Copies the input file to the output file.

translate.convert.convert.copytemplate(inputfile, outputfile, templatefile, **kwargs)

Copies the template file to the output file.

translate.convert.convert.should_output_store(store, threshold)

Check if the percent of translated source words more than or equal to the given threshold.

csv2po

Convert Comma-Separated Value (.csv) files to Gettext PO localization files.

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

translate.convert.csv2po.convertcsv(inputfile, outputfile, templatefile, charset=None, columnorder=None, duplicatestyle='msgctxt')

reads in inputfile using csvl10n, converts using csv2po, writes to outputfile

class translate.convert.csv2po.csv2po(templatepo=None, charset=None, duplicatestyle='keep')

a class that takes translations from a .csv file and puts them in a .po file

convertstore(thecsvfile)

converts a csvfile to a pofile, and returns it. uses templatepo if given at construction

convertunit(csvunit)

converts csv unit to po unit

handlecsvunit(csvunit)

handles reintegrating a csv unit into the .po file

makeindex()

makes indexes required for searching…

translate.convert.csv2po.replacestrings(source, *pairs)

Use pairs of (original, replacement) to replace text found in source.

Parameters:
  • source (String) – String to on which pairs of strings are to be replaced
  • *pairs (One or more tuples of (original, replacement)) – Strings to be matched and replaced
Returns:

String with *pairs of strings replaced

csv2tbx

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

translate.convert.csv2tbx.convertcsv(inputfile, outputfile, templatefile, charset=None, columnorder=None)

reads in inputfile using csvl10n, converts using csv2tbx, writes to outputfile

class translate.convert.csv2tbx.csv2tbx(charset=None)

a class that takes translations from a .csv file and puts them in a .tbx file

convertfile(csvfile)

converts a csvfile to a tbxfile, and returns it. uses templatepo if given at construction

dtd2po

Convert a Mozilla .dtd UTF-8 localization format to a Gettext PO localization file.

Uses the po and dtd modules, and the dtd2po convertor class which is in this module You can convert back to .dtd using po2dtd.py.

translate.convert.dtd2po.convertdtd(inputfile, outputfile, templatefile, pot=False, duplicatestyle='msgctxt')

reads in inputfile and templatefile using dtd, converts using dtd2po, writes to outputfile

translate.convert.dtd2po.is_css_entity(entity)

Says if the given entity is likely to contain CSS that should not be translated.

factory

Factory methods to convert supported input files to supported translatable files.

exception translate.convert.factory.UnknownExtensionError(afile)
exception translate.convert.factory.UnsupportedConversionError(in_ext=None, out_ext=None, templ_ext=None)

html2po

Convert HTML files to Gettext PO localization files.

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

translate.convert.html2po.converthtml(inputfile, outputfile, templates, includeuntagged=False, pot=False, duplicatestyle='msgctxt', keepcomments=False)

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

ical2po

Convert iCalendar files to Gettext PO localization files.

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

class translate.convert.ical2po.ical2po(input_file, output_file, template_file=None, blank_msgstr=False, duplicate_style='msgctxt')

Convert one or two iCalendar files to a single PO file.

SourceStoreClass

alias of translate.storage.ical.icalfile

TargetStoreClass

alias of translate.storage.pypo.pofile

TargetUnitClass

alias of translate.storage.pypo.pounit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

merge_stores()

Convert two source format files to a target format file.

run()

Run the converter.

translate.convert.ical2po.run_converter(input_file, output_file, template_file=None, pot=False, duplicatestyle='msgctxt')

Wrapper around converter.

ini2po

Convert .ini files to Gettext PO localization files.

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

class translate.convert.ini2po.ini2po(input_file, output_file, template_file=None, blank_msgstr=False, duplicate_style='msgctxt', dialect='default')

Convert one or two INI files to a single PO file.

SourceStoreClass

alias of translate.storage.ini.inifile

TargetStoreClass

alias of translate.storage.pypo.pofile

TargetUnitClass

alias of translate.storage.pypo.pounit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

merge_stores()

Convert two source format files to a target format file.

run()

Run the converter.

translate.convert.ini2po.run_converter(input_file, output_file, template_file=None, pot=False, duplicatestyle='msgctxt', dialect='default')

Wrapper around converter.

json2po

Convert JSON files to Gettext PO localization files.

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

translate.convert.json2po.convertjson(input_file, output_file, template_file, pot=False, duplicatestyle='msgctxt', dialect='default', filter=None)

Reads in input_file using jsonl10n, converts using json2po, writes to output_file.

class translate.convert.json2po.json2po

Convert a JSON file to a PO file

convert_store(input_store, duplicatestyle='msgctxt')

Converts a JSON file to a PO file

convert_unit(input_unit, commenttype)

Converts a JSON unit to a PO unit

Returns:None if empty or not for translation
merge_store(template_store, input_store, blankmsgstr=False, duplicatestyle='msgctxt')

Converts two JSON files to a PO file

moz2po

Convert Mozilla .dtd and .properties files to Gettext PO localization files.

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

mozfunny2prop

Converts additional Mozilla files to properties files.

translate.convert.mozfunny2prop.inc2po(inputfile, outputfile, templatefile, encoding=None, pot=False, duplicatestyle='msgctxt')

wraps prop2po but converts input/template files to properties first

translate.convert.mozfunny2prop.inc2prop(lines)

convert a .inc file with #defines in it to a properties file

translate.convert.mozfunny2prop.it2po(inputfile, outputfile, templatefile, encoding='cp1252', pot=False, duplicatestyle='msgctxt')

wraps prop2po but converts input/template files to properties first

translate.convert.mozfunny2prop.it2prop(lines, encoding='cp1252')

convert a pseudo-properties .it file to a conventional properties file

mozlang2po

Convert Mozilla .lang files to Gettext PO localization files.

class translate.convert.mozlang2po.lang2po(input_file, output_file, template_file=None, blank_msgstr=False, duplicate_style='msgctxt', encoding='utf-8')

Convert one Mozilla .lang file to a single PO file.

SourceStoreClass

alias of translate.storage.mozilla_lang.LangStore

TargetStoreClass

alias of translate.storage.pypo.pofile

TargetUnitClass

alias of translate.storage.pypo.pounit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

merge_stores()

Convert two source format files to a target format file.

run()

Run the converter.

translate.convert.mozlang2po.run_converter(input_file, output_file, template_file=None, pot=False, duplicatestyle='msgctxt', encoding='utf-8')

Wrapper around converter.

odf2xliff

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.

translate.convert.odf2xliff.convertodf(inputfile, outputfile, templates)

Convert an ODF package to XLIFF.

oo2po

Convert an OpenOffice.org (SDF) localization file to Gettext PO localization files.

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

translate.convert.oo2po.convertoo(inputfile, outputfile, templates, pot=False, sourcelanguage=None, targetlanguage=None, duplicatestyle='msgid_comment', multifilestyle='single')

reads in stdin using inputstore class, converts using convertorclass, writes to stdout

translate.convert.oo2po.verifyoptions(options)

verifies the commandline options

oo2xliff

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.

translate.convert.oo2xliff.convertoo(inputfile, outputfile, templates, pot=False, sourcelanguage=None, targetlanguage=None, duplicatestyle='msgctxt', multifilestyle='single')

reads in stdin using inputstore class, converts using convertorclass, writes to stdout

translate.convert.oo2xliff.verifyoptions(options)

verifies the commandline options

php2po

Convert PHP localization files to Gettext PO localization files.

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

class translate.convert.php2po.php2po(input_file, output_file, template_file=None, blank_msgstr=False, duplicate_style='msgctxt')

Convert one or two PHP files to a single PO file.

SourceStoreClass

alias of translate.storage.php.phpfile

TargetStoreClass

alias of translate.storage.pypo.pofile

TargetUnitClass

alias of translate.storage.pypo.pounit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

merge_stores()

Convert two source format files to a target format file.

run()

Run the converter.

translate.convert.php2po.run_converter(input_file, output_file, template_file=None, pot=False, duplicatestyle='msgctxt')

Wrapper around converter.

po2csv

Convert Gettext PO localization files to Comma-Separated Value (.csv) files.

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

translate.convert.po2csv.convertcsv(inputfile, outputfile, templatefile, columnorder=None)

reads in inputfile using po, converts using po2csv, writes to outputfile

po2dtd

Converts a Gettext PO file to a UTF-8 encoded Mozilla .dtd file.

translate.convert.po2dtd.applytranslation(entity, dtdunit, inputunit, mixedentities)

applies the translation for entity in the po unit to the dtd unit

class translate.convert.po2dtd.po2dtd(android=False, remove_untranslated=False)

this is a convertor class that creates a new dtd file based on a po file without a template

class translate.convert.po2dtd.redtd(dtdfile, android=False, remove_untranslated=False)

this is a convertor class that creates a new dtd based on a template using translations in a po

po2html

Convert Gettext PO localization files to HTML files.

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

translate.convert.po2html.converthtml(inputfile, outputfile, templatefile, includefuzzy=False, outputthreshold=None)

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

class translate.convert.po2html.po2html

po2html can take a po file and generate html. best to give it a template file otherwise will just concat msgstrs

mergestore(inputstore, templatetext, includefuzzy)

converts a file to .po format

po2ical

Convert Gettext PO localization files to iCalendar files.

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

class translate.convert.po2ical.po2ical(input_file, output_file, template_file=None, include_fuzzy=False, output_threshold=None)

Convert a PO file and a template iCalendar file to a iCalendar file.

SourceStoreClass

alias of translate.storage.pypo.pofile

TargetStoreClass

alias of translate.storage.ical.icalfile

TargetUnitClass

alias of translate.storage.ical.icalunit

merge_stores()

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()

Run the converter.

translate.convert.po2ical.run_converter(inputfile, outputfile, templatefile=None, includefuzzy=False, outputthreshold=None)

Wrapper around converter.

po2ini

Convert Gettext PO localization files to .ini files.

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

class translate.convert.po2ini.po2ini(input_file, output_file, template_file=None, include_fuzzy=False, output_threshold=None, dialect='default')

Convert a PO file and a template INI file to a INI file.

SourceStoreClass

alias of translate.storage.pypo.pofile

TargetStoreClass

alias of translate.storage.ini.inifile

TargetUnitClass

alias of translate.storage.ini.iniunit

merge_stores()

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()

Run the converter.

translate.convert.po2ini.run_converter(inputfile, outputfile, templatefile=None, includefuzzy=False, dialect='default', outputthreshold=None)

Wrapper around converter.

po2json

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.

po2mozlang

Convert Gettext PO localization files to Mozilla .lang files.

class translate.convert.po2mozlang.po2lang(input_file, output_file, template_file=None, include_fuzzy=False, output_threshold=None, mark_active=True)

Convert a PO file to a Mozilla .lang file.

SourceStoreClass

alias of translate.storage.pypo.pofile

TargetStoreClass

alias of translate.storage.mozilla_lang.LangStore

TargetUnitClass

alias of translate.storage.mozilla_lang.LangUnit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

run()

Run the converter.

translate.convert.po2mozlang.run_converter(inputfile, outputfile, templatefile=None, includefuzzy=False, mark_active=True, outputthreshold=None)

Wrapper around converter.

po2moz

Convert Gettext PO localization files to Mozilla .dtd and .properties files.

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

class translate.convert.po2moz.MozConvertOptionParser(formats, usetemplates=False, usepots=False, description=None)
add_duplicates_option(default='msgctxt')

Adds an option to say what to do with duplicate strings.

add_fuzzy_option(default=False)

Adds an option to include / exclude fuzzy translations.

add_multifile_option(default='single')

Adds an option to say how to split the po/pot files.

add_option(Option)

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

add_remove_untranslated_option(default=False)

Adds an option to remove key value from output if it is untranslated.

add_threshold_option(default=None)

Adds an option to output only stores where translation percentage exceeds the threshold.

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.

filterinputformats(options)

Filters input formats, processing relevant switches in options.

filteroutputoptions(options)

Filters output options, processing relevant switches in options.

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.

potifyformat(fileformat)

Converts a .po to a .pot where required.

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 convert files

run(argv=None)

Parses the command line options and runs the conversion.

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

setpotoption()

Sets the -P/--pot option depending on input/output formats etc.

setprogressoptions()

Sets the progress options.

settimestampoption()

Sets -S/--timestamp option.

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 a inputpath into name and extension

Special adaptation to handle po2moz case where extensions are e.g. properties.po

splittemplateext(templatepath)

Splits a templatepath into name and extension.

templateexists(options, templatepath)

Returns whether the given template exists…

verifyoptions(options)

Verifies that the options are valid (required options are present, etc).

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

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

po2oo

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.

po2php

Convert Gettext PO localization files to PHP localization files.

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

po2prop

Convert Gettext PO localization files to Java/Mozilla .properties files.

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

translate.convert.po2prop.applytranslation(key, propunit, inunit, mixedkeys)

applies the translation for key in the po unit to the prop unit

translate.convert.po2prop.convertmozillaprop(inputfile, outputfile, templatefile, includefuzzy=False, remove_untranslated=False, outputthreshold=None)

Mozilla specific convertor function

translate.convert.po2prop.convertstrings(inputfile, outputfile, templatefile, personality='strings', includefuzzy=False, encoding=None, outputthreshold=None, remove_untranslated=False)

.strings specific convertor function

po2rc

Convert Gettext PO localization files back to Windows Resource (.rc) files.

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

po2resx

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.

po2sub

Convert Gettext PO localization files to subtitle files.

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

po2symb

Convert Gettext PO localization files to Symbian translation files.

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

po2tiki

Convert Gettext PO files to TikiWiki’s language.php files.

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

class translate.convert.po2tiki.po2tiki(input_file, output_file, template_file=None)

Convert a PO file and a template TikiWiki file to a TikiWiki file.

SourceStoreClass

alias of translate.storage.pypo.pofile

TargetStoreClass

alias of translate.storage.tiki.TikiStore

TargetUnitClass

alias of translate.storage.tiki.TikiUnit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

run()

Run the converter.

translate.convert.po2tiki.run_converter(inputfile, outputfile, template=None)

Wrapper around converter.

po2tmx

Convert Gettext PO localization files to a TMX (Translation Memory eXchange) file.

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

class translate.convert.po2tmx.TmxOptionParser(formats, usetemplates=False, usepots=False, description=None, archiveformats=None)
add_duplicates_option(default='msgctxt')

Adds an option to say what to do with duplicate strings.

add_fuzzy_option(default=False)

Adds an option to include / exclude fuzzy translations.

add_multifile_option(default='single')

Adds an option to say how to split the po/pot files.

add_option(Option)

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

add_remove_untranslated_option(default=False)

Adds an option to remove key value from output if it is untranslated.

add_threshold_option(default=None)

Adds an option to output only stores where translation percentage exceeds the threshold.

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.

filterinputformats(options)

Filters input formats, processing relevant switches in options.

filteroutputoptions(options)

Filters output options, processing relevant switches in options.

finalizetempoutputfile(options, outputfile, fulloutputpath)

Write the temp outputfile to its final destination.

format_manpage()

returns a formatted manpage

getarchiveclass(fileext, filepurpose, isdir=False)

Returns the archiveclass for the given fileext and filepurpose

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

isarchive(fileoption, filepurpose='input')

Returns whether the file option is an archive file.

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).

openarchive(archivefilename, filepurpose, **kwargs)

Creates an archive object for the given file.

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.

potifyformat(fileformat)

Converts a .po to a .pot where required.

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)

Run an invidividual conversion.

recursearchivefiles(options)

Recurse through archive files and convert files.

recurseinputfilelist(options)

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

recurseinputfiles(options)

Recurse through archive file / directories and return files to be converted.

recursiveprocess(options)

Recurse through directories and convert files.

run(argv=None)

Parses the command line options and runs the conversion.

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

setpotoption()

Sets the -P/--pot option depending on input/output formats etc.

setprogressoptions()

Sets the progress options.

settimestampoption()

Sets -S/--timestamp option.

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…

verifyoptions(options)

Verifies that the options are valid (required options are present, etc).

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

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

translate.convert.po2tmx.convertpo(inputfile, outputfile, templatefile, sourcelanguage='en', targetlanguage=None, comment=None)

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

po2ts

Convert Gettext PO localization files to Qt Linguist (.ts) files.

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

translate.convert.po2ts.convertpo(inputfile, outputfile, templatefile, context)

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

po2txt

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.

class translate.convert.po2txt.po2txt(input_file, output_file, template_file=None, include_fuzzy=False, output_threshold=None, encoding='utf-8', wrap=None)

po2txt can take a po file and generate txt.

best to give it a template file otherwise will just concat msgstrs

convert_store()

Convert a source file to a target file.

merge_stores()

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()

Run the converter.

wrapmessage(message)

rewraps text as required

translate.convert.po2txt.run_converter(inputfile, outputfile, templatefile=None, wrap=None, includefuzzy=False, encoding='utf-8', outputthreshold=None)

Wrapper around converter.

po2web2py

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.

po2wordfast

Convert Gettext PO localization files to a Wordfast translation memory file.

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

class translate.convert.po2wordfast.WfOptionParser(formats, usetemplates=False, usepots=False, description=None, archiveformats=None)
add_duplicates_option(default='msgctxt')

Adds an option to say what to do with duplicate strings.

add_fuzzy_option(default=False)

Adds an option to include / exclude fuzzy translations.

add_multifile_option(default='single')

Adds an option to say how to split the po/pot files.

add_option(Option)

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

add_remove_untranslated_option(default=False)

Adds an option to remove key value from output if it is untranslated.

add_threshold_option(default=None)

Adds an option to output only stores where translation percentage exceeds the threshold.

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.

filterinputformats(options)

Filters input formats, processing relevant switches in options.

filteroutputoptions(options)

Filters output options, processing relevant switches in options.

finalizetempoutputfile(options, outputfile, fulloutputpath)

Write the temp outputfile to its final destination.

format_manpage()

returns a formatted manpage

getarchiveclass(fileext, filepurpose, isdir=False)

Returns the archiveclass for the given fileext and filepurpose

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

isarchive(fileoption, filepurpose='input')

Returns whether the file option is an archive file.

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).

openarchive(archivefilename, filepurpose, **kwargs)

Creates an archive object for the given file.

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.

potifyformat(fileformat)

Converts a .po to a .pot where required.

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)

Run an invidividual conversion.

recursearchivefiles(options)

Recurse through archive files and convert files.

recurseinputfilelist(options)

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

recurseinputfiles(options)

Recurse through archive file / directories and return files to be converted.

recursiveprocess(options)

Recurse through directories and convert files.

run(argv=None)

Parses the command line options and runs the conversion.

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

setpotoption()

Sets the -P/--pot option depending on input/output formats etc.

setprogressoptions()

Sets the progress options.

settimestampoption()

Sets -S/--timestamp option.

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…

verifyoptions(options)

Verifies that the options are valid (required options are present, etc).

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

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

translate.convert.po2wordfast.convertpo(inputfile, outputfile, templatefile, sourcelanguage='en', targetlanguage=None)

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

po2xliff

Convert Gettext PO localization files to XLIFF localization files.

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

translate.convert.po2xliff.convertpo(inputfile, outputfile, templatefile)

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

po2yaml

Convert Gettext PO localization files to YAML files.

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

class translate.convert.po2yaml.po2yaml(input_file, output_file, template_file=None, include_fuzzy=False, output_threshold=None)

Convert a PO file and a template YAML file to a YAML file.

SourceStoreClass

alias of translate.storage.pypo.pofile

TargetStoreClass

alias of translate.storage.yaml.YAMLFile

TargetUnitClass

alias of translate.storage.yaml.YAMLUnit

convert_unit(unit)

Convert a source format unit to a target format unit.

merge_stores()

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()

Run the converter.

translate.convert.po2yaml.run_converter(inputfile, outputfile, templatefile=None, includefuzzy=False, outputthreshold=None)

Wrapper around converter.

pot2po

Convert template files (like .pot or template .xlf files) to translation files, preserving existing translations.

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

translate.convert.pot2po.convert_stores(input_store, template_store, temp_store=None, tm=None, min_similarity=75, fuzzymatching=True, **kwargs)

Actual conversion function, works on stores not files, returns a properly initialized pretranslated output store, with structure based on input_store, metadata based on template_store, migrates old translations from template_store and pretranslating from TM.

translate.convert.pot2po.convertpot(input_file, output_file, template_file, tm=None, min_similarity=75, fuzzymatching=True, classes=None, classes_str=None, **kwargs)

Main conversion function.

prop2mozfunny

Converts properties files to additional Mozilla format files.

translate.convert.prop2mozfunny.po2inc(inputfile, outputfile, templatefile, encoding=None, includefuzzy=False, remove_untranslated=False, outputthreshold=None)

wraps po2prop but converts outputfile to properties first

translate.convert.prop2mozfunny.po2ini(inputfile, outputfile, templatefile, encoding='UTF-8', includefuzzy=False, remove_untranslated=False, outputthreshold=None)

wraps po2prop but converts outputfile to properties first using UTF-8 encoding

translate.convert.prop2mozfunny.po2it(inputfile, outputfile, templatefile, encoding='cp1252', includefuzzy=False, remove_untranslated=False, outputthreshold=None)

wraps po2prop but converts outputfile to properties first

translate.convert.prop2mozfunny.prop2inc(pf)

convert a properties file back to a .inc file with #defines in it

translate.convert.prop2mozfunny.prop2it(pf)

convert a properties file back to a pseudo-properties .it file

prop2po

Convert Java/Mozilla .properties files to Gettext PO localization files.

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

exception translate.convert.prop2po.DiscardUnit
translate.convert.prop2po.convertmozillaprop(inputfile, outputfile, templatefile, pot=False, duplicatestyle='msgctxt')

Mozilla specific convertor function

translate.convert.prop2po.convertprop(inputfile, outputfile, templatefile, personality='java', pot=False, duplicatestyle='msgctxt', encoding=None)

reads in inputfile using properties, converts using prop2po, writes to outputfile

translate.convert.prop2po.convertstrings(inputfile, outputfile, templatefile, personality='strings', pot=False, duplicatestyle='msgctxt', encoding=None)

.strings specific convertor function

class translate.convert.prop2po.prop2po(personality='java', blankmsgstr=False, duplicatestyle='msgctxt')

convert a .properties file to a .po file for handling the translation.

convertpropunit(store, unit, commenttype, mixbucket='properties')

Converts a unit from store to a po unit, keeping track of mixed names along the way.

mixbucket can be specified to indicate if the given unit is part of the template or the translated file.

convertstore(thepropfile)

converts a .properties file to a .po file…

convertunit(propunit, commenttype)

Converts a .properties unit to a .po unit. Returns None if empty or not for translation.

fold_gaia_plurals(postore)

Fold the multiple plural units of a gaia file into a gettext plural.

mergestore(origpropfile, translatedpropfile)

converts two .properties files to a .po file…

rc2po

Convert Windows RC files to Gettext PO localization files.

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

translate.convert.rc2po.convertrc(input_file, output_file, template_file, pot=False, duplicatestyle='msgctxt', charset=None, lang=None, sublang=None)

reads in input_file using rc, converts using rc2po, writes to output_file

class translate.convert.rc2po.rc2po

Convert a .rc file to a .po file for handling the translation.

convert_store(input_store, duplicatestyle='msgctxt')

converts a .rc file to a .po file…

convert_unit(input_unit, commenttype)

Converts a .rc unit to a .po unit. Returns None if empty or not for translation.

merge_store(template_store, input_store, blankmsgstr=False, duplicatestyle='msgctxt')

converts two .rc files to a .po file…

resx2po

Convert .Net Resource (.resx) to Gettext PO localisation files.

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

class translate.convert.resx2po.resx2po

Convert a RESX file to a PO file for handling translation

convert_store(input_store, duplicatestyle='msgctxt')

Converts a RESX file to a PO file

convert_unit(input_unit, commenttype)

Converts a RESX unit to a PO unit @return: None if empty or not for translation

merge_store(template_store, input_store, blankmsgstr=False, duplicatestyle='msgctxt')

Converts two RESX files to a PO file

sub2po

Convert subtitle files to Gettext PO localization files.

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

translate.convert.sub2po.convert_store(input_store, duplicatestyle='msgctxt')

converts a subtitle file to a .po file…

translate.convert.sub2po.convert_unit(input_unit, commenttype)

Converts a subtitle unit to a .po unit. Returns None if empty or not for translation.

translate.convert.sub2po.convertsub(input_file, output_file, template_file=None, pot=False, duplicatestyle='msgctxt')

Reads in input_file using translate.subtitles, converts using sub2po, writes to output_file.

translate.convert.sub2po.merge_store(template_store, input_store, blankmsgstr=False, duplicatestyle='msgctxt')

converts two subtitle files to a .po file…

symb2po

Convert Symbian localisation files to Gettext PO localization files.

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

tiki2po

Convert TikiWiki’s language.php files to Gettext PO localization files.

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

translate.convert.tiki2po.run_converter(input_file, output_file, template_file=None, includeunused=False)

Wrapper around converter.

class translate.convert.tiki2po.tiki2po(input_file, output_file, template_file=None, include_unused=False)

Convert one or two TikiWiki’s language.php files to a single PO file.

SourceStoreClass

alias of translate.storage.tiki.TikiStore

TargetStoreClass

alias of translate.storage.pypo.pofile

TargetUnitClass

alias of translate.storage.pypo.pounit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

run()

Run the converter.

ts2po

Convert Qt Linguist (.ts) files to Gettext PO localization files.

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

translate.convert.ts2po.convertts(inputfile, outputfile, templates, pot=False, duplicatestyle='msgctxt')

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

txt2po

Convert plain text (.txt) files to Gettext PO localization files.

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

translate.convert.txt2po.run_converter(input_file, output_file, template_file=None, duplicatestyle='msgctxt', encoding='utf-8', flavour=None, no_segmentation=False)

Wrapper around converter.

class translate.convert.txt2po.txt2po(input_file, output_file, template_file=None, duplicate_style='msgctxt', encoding='utf-8', flavour=None, no_segmentation=False)

Convert one plain text (.txt) file to a single PO file.

SourceStoreClass

alias of translate.storage.txt.TxtFile

TargetStoreClass

alias of translate.storage.pypo.pofile

TargetUnitClass

alias of translate.storage.pypo.pounit

convert_store()

Convert a single source format file to a target format file.

merge_stores()

Convert two source format files to a target format file.

run()

Run the converter.

web2py2po

Convert web2py translation dictionaries (.py) to GNU/gettext PO files.

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

xliff2odf

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.

translate.convert.xliff2odf.convertxliff(input_file, output_file, template)

Create a translated ODF using an ODF template and a XLIFF file.

translate.convert.xliff2odf.write_odf(template, output_file, dom_trees)

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.

xliff2oo

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.

xliff2po

Convert XLIFF localization files to Gettext PO localization files.

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

translate.convert.xliff2po.convertxliff(inputfile, outputfile, templates, duplicatestyle='msgctxt')

reads in stdin using fromfileclass, converts using convertorclass, writes to stdout

yaml2po

Convert YAML files to Gettext PO localization files.

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

translate.convert.yaml2po.run_converter(input_file, output_file, template_file=None, pot=False, duplicatestyle='msgctxt')

Wrapper around converter.

class translate.convert.yaml2po.yaml2po(input_file, output_file, template_file=None, blank_msgstr=False, duplicate_style='msgctxt')

Convert one or two YAML files to a single PO file.

SourceStoreClass

alias of translate.storage.yaml.YAMLFile

TargetStoreClass

alias of translate.storage.pypo.pofile

TargetUnitClass

alias of translate.storage.pypo.pounit

convert_store()

Convert a single source format file to a target format file.

convert_unit(unit)

Convert a source format unit to a target format unit.

merge_stores()

Convert two source format files to a target format file.

run()

Run the converter.