bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: [gettext] feature request: --use-first option for msgmerge


From: Bruno Haible
Subject: Re: [gettext] feature request: --use-first option for msgmerge
Date: Sun, 9 Sep 2007 02:02:52 +0200
User-agent: KMail/1.5.4

Hello Benno,

> When updating an existing PO file and wishing to replace any 
> existing translations with ones from a compendium, one has to use 
> the roundabout way of 'msgcat'.  To preserve everything else as is 
> and just change the msgstrs that are different in the compendium, 
> I'm using the following ugly script:
> 
>   # Standardize the messages for the second argument, using the
>   # first argument as a compendium and the third argument as POT.
> 
>   grep -m1 -B555  '^$'  $2  >/tmp/po-header  &&
>   msgcat --use-first --no-wrap  /tmp/po-header \
>          $1  $2  >/tmp/po-catalog  &&
>   msgmerge --no-wrap  /tmp/po-catalog  $3  >/tmp/po-new  &&
>   grep -m1 -B22222 '^#~ msg' /tmp/po-new | sed '$d' | sed '$d'
> 
> Whereas I would like to simply do:
> 
>   msgmerge --use-first --no-wrap  -C $1  $2  $3

Well, I tried your commands:

>   grep -m1 -B555  '^$'  $2  >/tmp/po-header  &&
>   msgcat --use-first --no-wrap  /tmp/po-header \
>          $1  $2  >/tmp/po-catalog  &&

This gave me the error
  msgcat: input file `$1' doesn't contain a header entry with a charset 
specification

So I replaced the commands with
  { /usr/bin/grep -m1 -B555  '^$'  $2 ; cat $1 ; } >/tmp/po-header
  msgcat --use-first --no-wrap  /tmp/po-header  $2  >/tmp/po-catalog
  msgmerge --no-wrap  /tmp/po-catalog  $3  > /tmp/po-new

The first two commands creates a PO file that contains first the compendium,
then the part of $2 without the overlap with the compendium. The third
command eliminates messages that occur in the compendium and not in the POT
file, and reorders the messages in the same order as the POT file.

Your fourth command produced an empty file for me in some cases; I think you
intended to do something similar to what "msgattrib --no-wrap --no-obsolete"
does.

But when I do

  msgmerge --no-wrap -C compendium+header $2 $3 > /tmp/po-merged

I get exactly the same result as your /tmp/po-new. The only thing I had to
do is to prepend a header

  msgid ""
  msgstr ""
  "MIME-Version: 1.0\n"
  "Content-Type: text/plain; charset=UTF-8\n"
  "Content-Transfer-Encoding: 8bit\n"

to the compendium. This is necessary because msgmerge cannot know the
encoding of the compendium otherwise. Your approach to copy the PO file's
header into the compendium will produce garbage if, for example, the
PO file is in ISO-8859-1 and the compendium is in UTF-8.

> Is such a --use-first option to msgmerge feasible?

I cannot see in what respect your expected output differs from what
"msgmerge --no-wrap  -C $1  $2  $3" already produces.

Can you please send an example, consisting of the 3 input files and your
expected output?

Bruno





reply via email to

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