28cf258
# ModulemdTranslationHelpers
28cf258
## Prerequisites
28cf258
* [libmodulemd](https://github.com/fedora-modularity/libmodulemd)
28cf258
* [koji](https://pagure.io/koji)
a7878c6
28cf258
To install on Fedora 28+, run:
28cf258
```
28cf258
dnf install libmodulemd koji
28cf258
```
28cf258
28cf258
## Installation
28cf258
With the prerequisites installed, the latest version can be installed with
28cf258
`pip install ModulemdTranslationHelpers` or on Fedora 28+ with `dnf install
28cf258
python3-ModulemdTranslationHelpers` (recommended).
28cf258
28cf258
## CLI Usage
28cf258
28cf258
### Extract Translatable Strings
28cf258
To extract translatable strings from modules for a particular Fedora
28cf258
release (e.g. f29):
28cf258
```
28cf258
ModulemdTranslationHelpers --branch f29 extract [--pot-file <path>]
28cf258
```
28cf258
This will read all of the module metadata from the Koji build-system and
28cf258
convert the translatable strings to a portable object template (`.pot`)
28cf258
document.
28cf258
28cf258
Specify the destination for the output file with `--pot-file`.
28cf258
28cf258
 ### Produce modulemd-translations YAML
28cf258
 To convert portable object (`.po`) files into
28cf258
 modulemd-translations YAML documents that can be included in repodata:
28cf258
 ```
28cf258
 ModulemdTranslationHelpers --branch f29 generate_metadata \
28cf258
                            [--pofile-dir <path>] \
28cf258
                            [--yaml-file <path>]
28cf258
28cf258
 ```
28cf258
28cf258
 This will read all files with a `.po` suffix in the `pofile-dir` path and
28cf258
 write the modulemd YAML to `yaml-file`.
28cf258
28cf258
## API
28cf258
### ModulemdTranslationHelpers
28cf258
The ModulemdTranslationHelpers package has two primary functions:
28cf258
* get_module_catalog_from_tags()
28cf258
* get_modulemd_translations()
28cf258
28cf258
#### ModulemdTranslationHelpers.get_module_catalog_from_tags()
28cf258
This returns a `babel.message.Catalog` object containing all of the
28cf258
translatable strings from any module tagged with one of the passed tags. It
28cf258
can be passed to `babel.messages.pofile.write_po()` to create a portable
28cf258
object template (`.pot`) file.
28cf258
28cf258
#### ModulemdTranslationHelpers.get_modulemd_translations()
28cf258
This returns an iterable of modulemd-translation objects generated from a
28cf258
set of paths to portable object (`.po`) files containing translation
28cf258
information.
28cf258
28cf258
### ModulemdTranslationHelpers.Fedora
28cf258
This package provides helper routines for dealing with translations in Fedora
28cf258
Modules.
28cf258
28cf258
#### ModulemdTranslationHelpers.Fedora.KOJI_URL
28cf258
The URL to the standard Fedora Koji instance.
28cf258
28cf258
#### ModulemdTranslationHelpers.Fedora.get_fedora_rawhide_version()
28cf258
Looks up which Fedora version the current Rawhide branch will become.
28cf258
28cf258
#### ModulemdTranslationHelpers.Fedora.get_tags_for_fedora_branch()
28cf258
Gets the list of tags for modules in a given Fedora branch. (For rawhide,
28cf258
make sure to use the value returned from get_fedora_rawhide_version.)