univention.l10n package#
- exception univention.l10n.Error[source]#
Bases:
SystemExit
- class univention.l10n.MIMEChecker[source]#
Bases:
object- suffixes = {'.html': 'text/html', '.js': 'application/javascript', '.py': 'text/x-python', '.sh': 'text/x-shellscript', '.ts': 'application/javascript', '.vue': 'application/javascript'}#
- class univention.l10n.SpecialCase(special_case_definition: dict[str, str], source_dir: str, path_to_definition: str, target_language: str)[source]#
Bases:
objectConsumes 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.
- RE_L10N = re.compile('(.+/)?debian/([^/]+).univention-l10n$')#
- get_source_file_sets() list[SourceFileSet][source]#
- class univention.l10n.UMCModuleTranslation(attrs: dict[str, Any], target_language: str)[source]#
Bases:
UMC_Module- classmethod from_source_package(module_in_source_tree: BaseModule, target_language: str) UMCModuleTranslation[source]#
- univention.l10n.create_new_package(new_package_dir: str, target_language: str, target_locale: str, language_name: str, startdir: str) None[source]#
- univention.l10n.find_base_translation_modules(source_dir: str) list[BaseModule][source]#
- univention.l10n.get_special_cases_from_checkout(source_tree_path: str, target_language: str) list[SpecialCase][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.l10n.get_special_cases_from_srcpkg(source_tree_path: str, target_language: str) list[SpecialCase][source]#
- univention.l10n.read_special_case_definition(definition_path: str, source_tree_path: str, target_language: str) Iterator[SpecialCase][source]#
- univention.l10n.template_file(dst: str, fn: str, values: dict[str, str]) None[source]#
Render file from template file by filling in values.
- Parameters:
dst – Destination path.
fn – File name for destination file and source template with .tmpl suffix.
values – A dictionary with the values.
- univention.l10n.translate_special_case(special_case: SpecialCase, source_dir: str, output_dir: str) None[source]#
- univention.l10n.update_package_translation_files(module: UMCModuleTranslation, output_dir: str, template: bool = False) None[source]#
- univention.l10n.write_makefile(all_modules: list[UMCModuleTranslation], special_cases: list[SpecialCase], new_package_dir: str, target_language: str) None[source]#
Submodules#
univention.l10n.cmd module#
Univention Corporate Server localization tool to extract, update, and compile GNU gettext Portable Objects (PO files) to Message Objects (MO files).
- univention.l10n.cmd.build(args: Namespace) None[source]#
Generate GNU gettext Portable Objects (PO files) from debian/*.univention-l10n files
This script reads
debian/*.univention-l10nfiles inside the current working directory and creates gettext Portable Objects defined within. It intends to facilitate and homogenize the translation build process.Add it to the build target inside
debian/rulesto build the POs for a certain language or use it manually inside source packages to update the translation catalog.Example
debian/rulesoverride:%: dh --with univention-l10n
or alternatively:
override_dh_auto_build: univention-l10n-build fr dh_auto_build
- univention.l10n.cmd.install(args: Namespace) None[source]#
Generate and install GNU gettext Message Objects (MO files) from debian/*.univention-l10n files.
This script reads
debian/*univention-l10nfiles inside the current working directory. It builds the message catalogs and installs them to the path defined within.The intended usage is to add it to the install target inside
debian/rulesto automate in-package translations.Example file: debian/rules override:
%: dh --with univention-l10n
or alternatively:
override_dh_auto_install: univention-l10n-install fr dh_auto_install
univention.l10n.helper module#
- exception univention.l10n.helper.Error[source]#
Bases:
SystemExit
univention.l10n.l10n module#
- class univention.l10n.l10n.UMCModuleTranslation(attrs: dict[str, Any], target_language: str)[source]#
Bases:
UMC_Module- classmethod from_source_package(module_in_source_tree: BaseModule, target_language: str) UMCModuleTranslation[source]#
- class univention.l10n.l10n.SpecialCase(special_case_definition: dict[str, str], source_dir: str, path_to_definition: str, target_language: str)[source]#
Bases:
objectConsumes 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.
- RE_L10N = re.compile('(.+/)?debian/([^/]+).univention-l10n$')#
- get_source_file_sets() list[SourceFileSet][source]#
- class univention.l10n.l10n.MIMEChecker[source]#
Bases:
object- suffixes = {'.html': 'text/html', '.js': 'application/javascript', '.py': 'text/x-python', '.sh': 'text/x-shellscript', '.ts': 'application/javascript', '.vue': 'application/javascript'}#
- univention.l10n.l10n.update_package_translation_files(module: UMCModuleTranslation, output_dir: str, template: bool = False) None[source]#
- univention.l10n.l10n.write_makefile(all_modules: list[UMCModuleTranslation], special_cases: list[SpecialCase], new_package_dir: str, target_language: str) None[source]#
- univention.l10n.l10n.translate_special_case(special_case: SpecialCase, source_dir: str, output_dir: str) None[source]#
- univention.l10n.l10n.read_special_case_definition(definition_path: str, source_tree_path: str, target_language: str) Iterator[SpecialCase][source]#
- univention.l10n.l10n.get_special_cases_from_srcpkg(source_tree_path: str, target_language: str) list[SpecialCase][source]#
- univention.l10n.l10n.get_special_cases_from_checkout(source_tree_path: str, target_language: str) list[SpecialCase][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.l10n.l10n.find_base_translation_modules(source_dir: str) list[BaseModule][source]#
univention.l10n.message_catalogs module#
This module collects utilities for installing and building message catalogs while applying Univention specific options.
- univention.l10n.message_catalogs.concatenate_po(src_po_path: str, dest_po_path: str) None[source]#
Append first to second .po file.
- Parameters:
src_po_path – File to merge.
dest_po_path – File to merge into.
- univention.l10n.message_catalogs.create_empty_po(binary_pkg_name: str, new_po_path: str) None[source]#
Create a new empty .po file.
- Parameters:
binary_pkg_name – Package name.
new_po_path – File name for new file.
- univention.l10n.message_catalogs.merge_po(template: str, translation: str) None[source]#
Merge old translation with new template file.
- Parameters:
template – New template .pot file.
translation – Old translation .po file.
- univention.l10n.message_catalogs.join_existing(language: str, output_file: str, input_files: str | list[str], cwd: str = '/builds/univention/dev/docs/ucsapidoc') None[source]#
Extract strings from source code and merge into existing translation file.
- Parameters:
language – Source code language, e.g. JavaScript, Python, Shell.
output_file – Template file name.
input_files – Sequence of input files.
cwd – Base directory used as new woring directory.
univention.l10n.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.
- class univention.l10n.sourcefileprocessing.SourceFileSet(src_pkg_path: str, binary_pkg_name: str, files: Iterable[str])[source]#
Bases:
object
- class univention.l10n.sourcefileprocessing.SourceFilesXgettext(src_pkg_path: str, binary_pkg_name: str, files: Iterable[str])[source]#
Bases:
SourceFileSet
- class univention.l10n.sourcefileprocessing.SourceFilesShell(src_pkg_path: str, binary_pkg_name: str, files: Iterable[str])[source]#
Bases:
SourceFilesXgettext
- class univention.l10n.sourcefileprocessing.SourceFilesPython(src_pkg_path: str, binary_pkg_name: str, files: Iterable[str])[source]#
Bases:
SourceFilesXgettext
- class univention.l10n.sourcefileprocessing.SourceFilesJavaScript(src_pkg_path: str, binary_pkg_name: str, files: Iterable[str])[source]#
Bases:
SourceFilesXgettext
- class univention.l10n.sourcefileprocessing.SourceFilesHTML(src_pkg_path: str, binary_pkg_name: str, files: Iterable[str])[source]#
Bases:
SourceFileSet
- class univention.l10n.sourcefileprocessing.SourceFileSetCreator[source]#
Bases:
object- process_by_type = {'application/javascript': <class 'univention.l10n.sourcefileprocessing.SourceFilesJavaScript'>, 'text/html': <class 'univention.l10n.sourcefileprocessing.SourceFilesHTML'>, 'text/x-python': <class 'univention.l10n.sourcefileprocessing.SourceFilesPython'>, 'text/x-shellscript': <class 'univention.l10n.sourcefileprocessing.SourceFilesShell'>}#
univention.l10n.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>.jsCategory: 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
- univention.l10n.umc.read_modules(package: str, core: bool = False) list[UMC_Module][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.
- univention.l10n.umc.module_xml2po(module: UMC_Module, po_file: str, language: str, template: bool = False) None[source]#
Create a PO file the XML definition of an UMC module.
- Parameters:
module – UMC module.
po_file – File name of the textual message catalog.
language – 2-letter language code.
template – Keep PO template file.
- univention.l10n.umc.create_po_file(po_file: str, package: str, files: str | Iterable[str], language: str = 'python', template: bool = False) None[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.
template – Keep PO template file.
- univention.l10n.umc.merge_po_file(po_file: str, pot_file: str) None[source]#
Merge
.pofile with new.potfile.- Parameters:
po_file – PO file containing translation.
pot_file – PO template file.
- univention.l10n.umc.create_mo_file(po_file: str, mo_file: str = '') None[source]#
Compile textual message catalog (.po) to binary message catalog (.mo).
- Parameters:
po_file – File name of the textual message catalog.
mo_file – File name of compiled message catalog.