|
| 1 | +# mmdzanata |
| 2 | +## Prerequisites |
| 3 | +* [libmodulemd](https://github.com/fedora-modularity/libmodulemd) |
| 4 | +* [koji](https://pagure.io/koji) |
| 5 | +* [zanata-client](https://github.com/zanata/zanata-client) |
| 6 | + |
| 7 | +To install on Fedora 28+, run: |
| 8 | +``` |
| 9 | +dnf install libmodulemd koji zanata-client |
| 10 | +``` |
| 11 | + |
| 12 | +## Installation |
| 13 | +With the prerequisites installed, the latest version can be installed with |
| 14 | +`pip install mmdzanata` or on Fedora 28+ with `dnf install mmdzanata` |
| 15 | +(recommended). |
| 16 | + |
| 17 | +## CLI Usage |
| 18 | +### Zanata Client Setup |
| 19 | +Use of the upload feature for string extraction requires setting up the |
| 20 | +Zanata client appropriately. Follow the |
| 21 | +[instructions](http://docs.zanata.org/en/release/client/configuration/) from |
| 22 | +Zanata to set up your `~/.config/zanata.ini` file appropriately. Note that |
| 23 | +you will want to do this against |
| 24 | +https://fedora.zanata.org |
| 25 | +and not |
| 26 | +https://translate.zanata.org |
| 27 | + |
| 28 | +### Extract Translatable Strings |
| 29 | +To extract translatable strings from modules for a particular Fedora |
| 30 | +release (e.g. f29): |
| 31 | +``` |
| 32 | +mmdzanata --branch f29 extract [--upload] |
| 33 | +``` |
| 34 | +This will read all of the module metadata from the Koji build-system and |
| 35 | +convert the translatable strings to a Zanata-compatible gettext document. If |
| 36 | + `--upload` is passed, it will also attempt to use the `zanata-cli` tool to |
| 37 | + upload the strings to the Zanata server. See the "Zanata Client Setup" |
| 38 | + section above for information on how to configure this. |
| 39 | + |
| 40 | + ### Produce modulemd-translations YAML |
| 41 | + To read the translated strings from Zanata and convert them into |
| 42 | + modulemd-translations YAML documents that can be included in repodata: |
| 43 | + ``` |
| 44 | + mmdzanata --branch f29 generate_modulemd |
| 45 | + ``` |
| 46 | + |
| 47 | + This will produce a YAML file in the current directory with all known |
| 48 | + translated strings. |
| 49 | + |
| 50 | +## API |
| 51 | +### mmdzanata |
| 52 | +The mmdzanata class has two primary methods: |
| 53 | +* get_module_catalog_from_tags() |
| 54 | +* generate_metadata() |
| 55 | + |
| 56 | +#### mmdzanata.get_module_catalog_from_tags() |
| 57 | +This returns a babel.message.Catalog object containing all of the |
| 58 | +translatable strings from any module tagged with one of the passed tags. |
| 59 | + |
| 60 | +#### mmmdzanata.generate_metadata() |
| 61 | +This returns an iterable of modulemd-translation objects from the supplied |
| 62 | +Zanata project and branch. |
| 63 | + |
| 64 | +### mmdzanata.fedora |
| 65 | +This class provides helper routines for dealing with translations in Fedora |
| 66 | +Modules. |
0 commit comments