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

Re: Utility to unfuzzy one specific msgstr in .po files?



Quoting Tobias Toedter (t.toedter@gmx.net):

> > There are other ways, more elaborated, to do preventive modification
> > of PO files (for instance by using sed)....which allow the 
> > "unfuzzyfication" process to be done even on incomplete files....but 
> > this is gory enough for being left to people who *really* are sure of 
> > what they do...:-) 
> 
> This seems to be what I was looking for. Christian, are you willing to share 
> those elaborated ways?


Yep. Hang on. Gory scripting follows....


Let's assume you need to change "Bier" to "beer" in the original
templates file (debian/mypackage.templates)...

As you mentioned, if you do so with no care, you will fuzzy one string
in all translations. Obviously, in such case, these do not need
changes and avoiding the new fuzzy string is needed.

Thus, do:

cd debian/po
for i in *po ; do
 echo -n $i: 
 msgfmt -o /dev/null --statistics $i
 cat $i | sed 's/Bier/beer/g' >$i
done
cd ..
vi debian/mypackage.templates
  <modify it and only do this modification...could have been done with
   sed also>
debconf-updatepo
cd debian/po
for i in *po ; do
 echo -n $i: 
 msgfmt -o /dev/null --statistics $i
done

The first loop will output the statistics of each PO file before the
change and will "preventively" replace the incorrect word by the right
one. The output is of course not mandatory and you may omit the "echo"
and "msgfmt" lines.

The, after you change the templates files, debconf-updatepo will
regenerate a POT file, merge all POs with it...and, miracle!, it will
find that these POs already have a translation for the changed string.

And the final loop is here for you to check that everything went OK.
The statistics for each PO file, complete or not, should not have changed.
This final loop is also not mandatory but recommended.

Be aware that this needs a recent sed to be able to "cat file | sed ....>file"
On woody machines, you need sed to output to an intermediate file.

This method is the simplest but not always the most appropriate,
particularly if it is likely that the thing you want to change could
ALSO occur in msgstr. You need then to choose your sed replacement
instruction very carefully so that it fits what you change...but only
that!

In such case, you may need to first "msgcat --no-wrap $i >$i.new" then
"sed 's/^msgid/s/Bier/beer/g'" on it in order to operate only on
msgids. After that, please do "msgcat $i.new >$i" to wrap again the PO
files....




Reply to: