Skip to content

Commit dd44348

Browse files
committed
Add usage documentation for pybabel concat and merge commands
* Includes .rst file with detailed use cases and practical examples for pybabel's concat and merge utilities, outlining common scenarios, options, and best practices for managing PO files.
1 parent 1817bce commit dd44348

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

docs/concat_merge_usage.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Usage scenarios
2+
---------------
3+
4+
1. Merging Multiple PO Files (`concat`)
5+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6+
7+
**Usage:**
8+
`pybabel concat [options] <po_files>`
9+
Suppose you manage a project with several PO files for the same language (for example, modules or plugins have their own translations), and you want to combine them into a single file for further work or for delivery to translators.
10+
11+
**Example:**
12+
13+
.. code-block:: shell
14+
15+
pybabel concat -o merged.po module1.po module2.po module3.po
16+
17+
**Features:**
18+
19+
- If the same string has different translations in different files, the resulting file for that string will include a special comment ``#-#-#-#-# <file> (PROJECT VERSION) #-#-#-#-#`` and the message will be marked with the ``fuzzy`` flag—this is useful for later manual conflict resolution.
20+
- You can keep only unique strings using the ``-u`` (`--less-than=2`) option.
21+
- Use `--use-first` to take only the first encountered translation for each string, skipping automatic merging of multiple options.
22+
- Output can be sorted alphabetically or by source file (options `-s`, `-F`).
23+
24+
**Typical Use Case:**
25+
26+
A project has translations from different teams. Before releasing, you need to gather all translations into one file, resolve possible conflicts, and provide the finalized version to translators for review.
27+
28+
29+
2. Updating Translations with a Template and Compendium (`merge`)
30+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31+
32+
**Usage:**
33+
`pybabel merge [options] def.po ref.pot`
34+
You need to update an existing translation file (`def.po`) based on a new template (`ref.pot`), reusing translations from an additional translation memory (compendium).
35+
36+
**Example:**
37+
38+
.. code-block:: shell
39+
40+
pybabel merge -C my-compendium.po --backup def.po ref.pot
41+
42+
**Features:**
43+
44+
- The compendium (`-C`) allows you to pull translations from a shared translation memory. Multiple compendiums can be used.
45+
- By default, translations from the compendium are used only for new or missing entries in `def.po`.
46+
- The `--compendium-overwrite` option allows overwriting existing translations with those found in the compendium (helpful for terminology standardization).
47+
- When a translation from the compendium is used, a comment is automatically added (this can be disabled with `--no-compendium-comment`).
48+
- The `--backup` flag saves a backup copy of your file before updating (`~` suffix by default, configurable with `--suffix`).
49+
50+
**Typical Use Case:**
51+
52+
After a release, a new translation template is provided. The team decides to enrich the translation by leveraging a common compendium in order to improve quality and unify terms. The merge command is run with the compendium and backup options enabled.

0 commit comments

Comments
 (0)