[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is the standard way to extract references in a PO file?

From: Bruno Haible
Subject: Re: What is the standard way to extract references in a PO file?
Date: Wed, 09 Jun 2021 15:51:39 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-210-generic; KDE/5.18.0; x86_64; ; )


Etienne Rouxel asked:
> Is there a standard way to extract references in a PO file?
> Must we extract each reference in a dedicated line line so:
>     ```po #: src/msgcmp.c:338 #: src/po-lex.c:699 ```
> or join them all in a single reference line like so:
>     ```po #: src/msgcmp.c:338 src/po-lex.c:699 ```
> The documentation 
> (https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html) 
> hints a the second style by giving an example of it. However, there is 
> no explicit mention about what is the right way, if there is any.

     #: src/msgcmp.c:338
     #: src/po-lex.c:699


     #: src/msgcmp.c:338 src/po-lex.c:699

are equivalent.

When creating a PO file or POT file, a tool can emit one reference
per line, or several references per line.

When reading a PO file, a tool should treat both ways as equivalent.
One way to do so is to use the GNU libgettextpo library and in particular
its file positions API

> This creates compatibility problems with tools involved in working with 
> PO files. A program can extract the references from the source code 
> using one style and the translation program used by the translator can 
> rewrite the references with the other style. That leads to complicated 
> merges of the translations back into the code repository.

Ah, the merges are the problem. In this case, I recommend to normalize
the PO files before commit. Normalizing means eliminating the possible
variations. A reasonable normalization command is to pipe the PO file
   msgcat --width=80


reply via email to

[Prev in Thread] Current Thread [Next in Thread]