univention.translationhelper package

Submodules

univention.translationhelper.helper module

univention.translationhelper.helper.make_parent_dir(path)[source]

Create parent directories for file.

Parameters:path – Path for a file.
univention.translationhelper.helper.call(*argv)[source]

Execute argv and wait.

Parameters:args – List of command and arguments.
>>> call('true')
0

univention.translationhelper.message_catalogs module

This module collects utilities for installing and building message catalogs while applying Univention specific options.

Currently this is mostly a wrapper for gettext. In the future it might be useful to merge parts of dh_umc into it as the UMC uses a custom JSON based catalog format.

exception univention.translationhelper.message_catalogs.GettextError[source]

Bases: exceptions.Exception

univention.translationhelper.message_catalogs._clean_header(po_path)[source]
univention.translationhelper.message_catalogs.concatenate_po(src_po_path, dest_po_path)[source]
univention.translationhelper.message_catalogs.create_empty_po(binary_pkg_name, new_po_path)[source]
univention.translationhelper.message_catalogs.compile_mo(path_to_po, mo_output_path)[source]
univention.translationhelper.message_catalogs.merge_po(source_po_path, dest_po_path)[source]
univention.translationhelper.message_catalogs.join_existing(language, output_file, input_files, cwd='/var/lib/jenkins/workspace/Mitarbeiter/phahn/UCS-API-Doc')[source]
univention.translationhelper.message_catalogs.po_to_json(po_path, json_output_path)[source]
univention.translationhelper.message_catalogs._call_gettext(*args, **kwargs)[source]
univention.translationhelper.message_catalogs.univention_location_lines(pot_path, abs_path_source_pkg)[source]

univention.translationhelper.sourcefileprocessing module

Generate gettext Portable Objects and message catalogs (gettext MO and a Univention specific JSON-based format) from multiple source files by file type.

exception univention.translationhelper.sourcefileprocessing.UnsupportedSourceType[source]

Bases: exceptions.Exception

class univention.translationhelper.sourcefileprocessing.SourceFileSet(src_pkg_path, binary_pkg_name, files)[source]

Bases: object

process_po(pot_path)[source]
process_target(po_path, output_path)[source]
_create_po_template(pot_path)[source]
_compile(po_path, output_path)[source]
class univention.translationhelper.sourcefileprocessing.SourceFilesXgettext(src_pkg_path, binary_pkg_name, files)[source]

Bases: univention.translationhelper.sourcefileprocessing.SourceFileSet

_create_po_file(gettext_lang, pot_path)[source]
_compile(po_path, mo_output_path)[source]
class univention.translationhelper.sourcefileprocessing.SourceFilesShell(src_pkg_path, binary_pkg_name, files)[source]

Bases: univention.translationhelper.sourcefileprocessing.SourceFilesXgettext

_create_po_template(pot_path)[source]
class univention.translationhelper.sourcefileprocessing.SourceFilesPython(src_pkg_path, binary_pkg_name, files)[source]

Bases: univention.translationhelper.sourcefileprocessing.SourceFilesXgettext

_create_po_template(pot_path)[source]
class univention.translationhelper.sourcefileprocessing.SourceFilesJavaScript(src_pkg_path, binary_pkg_name, files)[source]

Bases: univention.translationhelper.sourcefileprocessing.SourceFilesXgettext

_create_po_template(pot_path)[source]
_compile(po_path, json_output_path)[source]

With UMC and univention-web based applications a custom, JSON-based message format is used.

class univention.translationhelper.sourcefileprocessing.SourceFilesHTML(src_pkg_path, binary_pkg_name, files)[source]

Bases: univention.translationhelper.sourcefileprocessing.SourceFileSet

_create_po_template(pot_path)[source]
_compile(po_path, json_output_path)[source]
class univention.translationhelper.sourcefileprocessing.SourceFileSetCreator[source]

Bases: object

process_by_type = {'application/javascript': <class 'univention.translationhelper.sourcefileprocessing.SourceFilesJavaScript'>, 'text/html': <class 'univention.translationhelper.sourcefileprocessing.SourceFilesHTML'>, 'text/x-python': <class 'univention.translationhelper.sourcefileprocessing.SourceFilesPython'>, 'text/x-shellscript': <class 'univention.translationhelper.sourcefileprocessing.SourceFilesShell'>}
classmethod from_mimetype(src_pkg_path, binary_pkg_name, mimetype, files)[source]
univention.translationhelper.sourcefileprocessing.from_mimetype(src_pkg_path, binary_pkg_name, mimetype, files)[source]

univention.translationhelper.translationhelper module

exception univention.translationhelper.translationhelper.NoSpecialCaseDefintionsFound[source]

Bases: exceptions.Exception

class univention.translationhelper.translationhelper.UMCModuleTranslation(attrs, target_language)[source]

Bases: univention.translationhelper.umc.UMC_Module

python_po_files
js_po_files
xml_po_files
python_mo_destinations()[source]
json_targets()[source]
xml_mo_destinations()[source]
classmethod from_source_package(module_in_source_tree, target_language)[source]
static _read_module_attributes_from_source_package(module)[source]
classmethod _get_core_module_from_source_package(module, target_language)[source]
classmethod _get_module_from_source_package(module, target_language)[source]
class univention.translationhelper.translationhelper.SpecialCase(special_case_definition, source_dir, path_to_definition, target_language)[source]

Consumes special case definition and determines matching sets of source files.

Parameters:
  • special_case_definition – Mapping with special case definitions.
  • source_dir – Base directory.
  • path_to_definition – Path to definition file.
  • target_language – 2-letter language code.
_get_files_matching_patterns()[source]
get_source_file_sets()[source]
create_po_template(output_path='.')[source]
class univention.translationhelper.translationhelper.MIMEChecker[source]
suffixes = {'.js': 'application/javascript', '.html': 'text/html', '.sh': 'text/x-shellscript', '.py': 'text/x-python'}
get(file_path)[source]
univention.translationhelper.translationhelper.update_package_translation_files(module, output_dir)[source]
univention.translationhelper.translationhelper.write_makefile(all_modules, special_cases, new_package_dir, target_language)[source]
univention.translationhelper.translationhelper.translate_special_case(special_case, source_dir, output_dir)[source]
univention.translationhelper.translationhelper.read_special_case_definition(definition_path, source_tree_path, target_language)[source]
univention.translationhelper.translationhelper.get_special_cases_from_srcpkg(source_tree_path, target_language)[source]
univention.translationhelper.translationhelper.get_special_cases_from_checkout(source_tree_path, target_language)[source]

Process *.univention-l10n files in the whole branch. Currently they lay 3 (UCS@school) or 4(UCS) directory levels deep in the repository.

univention.translationhelper.translationhelper.find_base_translation_modules(startdir, source_dir, module_basefile_name)[source]
univention.translationhelper.translationhelper.write_debian_rules(debian_dir_path)[source]
univention.translationhelper.translationhelper.create_new_package(new_package_dir, target_language, target_locale, language_name, startdir)[source]

univention.translationhelper.umc module

Each module definition contains the following entries:

  • Module: The internal name of the module
  • Python: A directory containing the Python module. There must be a subdirectory named like the internal name of the module.
  • Definition: The XML definition of the module
  • Javascript: The directory of the javascript code. In this directory must be a a file called <Module>.js
  • Category: The XML definition of additional categories
  • Icons: A directory containing the icons used by the module. The directory structure must follow the following pattern <weight>x<height>/<icon>.(png|svg).

The entries Module and Definition are required.

Example:

Module: ucr
Python: umc/module
Definition: umc/ucr.xml
Javascript: umc/js
Category: umc/categories/ucr.xml
Icons: umc/icons
exception univention.translationhelper.umc.Error[source]

Bases: exceptions.SystemExit

class univention.translationhelper.umc.UMC_Module(*args)[source]

Bases: dict

_iter_files(base, suffix)[source]

Iterate over all files below base ending with suffix.

css_files

Iterate over all Javascript CSS files.

html_files

Iterate over all JavaScript HTML files.

icons

Return path to UMC icon directory.

js_files

Iterate over all JavaScript UMC files.

js_module_file

Return path to main JavaScript file.

js_path

Return path to JavaScript UMC directory.

js_po_files

Iterate over all JavaScript UMC message catalogs.

module_name

Return the name of the UMC module.

package

Return the name of the Debian binary package.

python_files

Iterate over all Python UMC files.

python_path

Return path to Python UMC directory.

python_po_files

Iterate over all Python UMC message catalogs.

python_versions
xml_categories

Return the path to the XML file defining categories.

xml_definition

Return the path to the XML UMC definition.

xml_po_files

Iterate over all XML UMC message catalogs.

univention.translationhelper.umc.create_json_file(po_file)[source]

Compile textual message catalog (.po) to JSON message catalog.

Parameters:po_file – File name of the textual message catalog.
univention.translationhelper.umc.create_mo_file(po_file)[source]

Compile textual message catalog (.po) to binary message catalog (.mo).

Parameters:po_file – File name of the textual message catalog.
univention.translationhelper.umc.create_po_file(po_file, package, files, language='python')[source]

Create a PO file for a defined set of files.

Parameters:
  • po_file – File name of the textual message catalog.
  • package – Name of the package.
  • files – A single file name or a list of file names.
  • language – Programming language name.
univention.translationhelper.umc.module_xml2po(module, po_file, language)[source]

Create a PO file the XML definition of an UMC module.

Parameters:
  • moduleUMC module.
  • po_file – File name of the textual message catalog.
  • language – 2-letter language code.
univention.translationhelper.umc.read_modules(package, core=False)[source]

Read UMC module definition from debian/<package>.umc-modules.

Parameters:
  • package – Name of the package.
  • core – Import as core-module, e.g. the ones shipped with UDM itself.
Returns:

List of UMC module definitions.