Generating po files manually - problems with msgmerge

Discuss and coordinate development of mainline and user-made content translations.

Moderator: Forum Moderators

Post Reply
szopen
Posts: 631
Joined: March 31st, 2005, 12:51 pm

Generating po files manually - problems with msgmerge

Post by szopen »

EDIT: the temporary solution below
Hi there,

I made the following steps in order to manually create .po files. This is because i am a bit impatient, and because it seems that #po: comments does not work at WesCamp unless I will manually regenerate .pot file (or do they?).

I did following steps:

1. cd $wesnoth_local_dir/campaigns
2. git clone git://github.com/wescamp/A_New_Order-1.10.git
3. cd A_New_Order
4. make
the .pot file is nicely regenerated with proper comments, however, the make breaks on running msgmerge with 1132 errors. Some of them were related to newlines within definitions, so I could manually correct those. The rest, about 922 errors, are "repeated definition at line X.. earlier definition at line Y".

Any ideas what to do with those, except from "poke espreon until he either solves the problem or sends assasin pack on you" ?

EDIT:
5. msguniq -u wesnoth-A_New_Order.pot >new.po
6. msgmerge pl.po new.po -o pl2.po

It works, but all comments are missing :(
If I will do the other way (msgmerge new.po pl.po -o pl2.po) thecomments are preserved, but almost whole translation (as it could be expected) is missing...

EDIT2:
msgcat does not do the tricks. It does add some of the #comments, but not all of them.

EDIT3:
solved, at least partially, with msgcomm. The last problems I have are:
1) Some errors generated by msgmerge are "newlines within strings", errors, which could be easily solved in automatic way I suppose. Since I have only 5 or 6 such errors, I corrected them manually, but it is something for wmlxgettext maintainers to consider.
2) wmlxgettext generates awful amount of comments, some of which are completely useless:

# 01_blabla line 10: [if] has

I solved this with some grep -v commands, but I'm affraid I could lost some information during the process.

3) OTOH, the great thing is adding a context, but it is sometimes not enough: e.g. for {MSG_Lorin _"Blah!"} the context {MSG_Lorin is great, but for {MESSAGE (Lady Lorin) _"Blah"} the context {MESSAGE is almost useless. This would be very hard to solve in automatic way, I know, but still for me it is an issue.

EDIT4:
In case someone finds it useful, I used the following: full procedure below.

1) 1-4 steps as above

Code: Select all

 cd $wesnoth_local_dir/campaigns
 git clone git://github.com/wescamp/A_New_Order-1.10.git
 cd A_New_Order
 make 
2) manually edited strings containing newlines, e.g.

Code: Select all

       msgstr "
       Forces of Darkness, come to my Aid -
into:

Code: Select all

msgstr ""
       "Forces of Darkness, come to my Aid -\n"
3)

Code: Select all

grep -v "<toplevel>" wesnoth-A_New_Order.pot > tmp; mv tmp wesnoth-A_New_Order.pot
grep -v "\] has $" wesnoth-A_New_Order.pot > tmp; mv tmp wesnoth-A_New_Order.pot
grep -v "{UNIT$" wesnoth-A_New_Order.pot > tmp; mv tmp wesnoth-A_New_Order.pot
grep -v "\[if\]" wesnoth-A_New_Order.pot > tmp; mv tmp wesnoth-A_New_Order.pot
grep -v "\[then\]" wesnoth-A_New_Order.pot > tmp; mv tmp wesnoth-A_New_Order.pot
grep -v "\[else\]" wesnoth-A_New_Order.pot > tmp; mv tmp wesnoth-A_New_Order.pot
grep -v "\[scenario\]" wesnoth-A_New_Order.pot > tmp; mv tmp wesnoth-A_New_Order.pot
The other comments I decided to leave, as they may be useful.

4.

Code: Select all

 msguniq -u wesnoth-A_New_Order.pot >tmp; mv tmp wesnoth-A_New_Order.pot
5.

Code: Select all

 msgcomm wesnoth-A_New_Order.pot pl.po > tmp; mv tmp pl.po 
However, after this I have lost approximately half of the strings. I used msgcomm to recover some, but still I lost the strings from _main.cfg. I am stuck.
"Even when the Slav is gay the effort is often evident" -- P. R. RADOSAVLJEVICH
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Generating po files manually - problems with msgmerge

Post by AI »

First quick reply (I haven't finished reading your post yet): msgmerge (in fact, the whole makefile) works fine on my machine, and I don't see any po: comments in ANO.

What system are you running this on?

EDIT: Having now read your entire post, I still have no idea what is causing your problems.
szopen
Posts: 631
Joined: March 31st, 2005, 12:51 pm

Re: Generating po files manually - problems with msgmerge

Post by szopen »

I work on a :
Distributor ID: SUSE LINUX
Description: openSUSE 11.4 (i586)
Release: 11.4
Codename: Celadon
One error was caused by my own stupidity (msguniq should be without -u, no idea one I have put it there). Obviously, I am doing something wrong, since previous .po files contained also the strings, which I have trouble to regenerate. Seems that wmlxgettext has problem with extracting strings from the following:
#textdomain wesnoth-A_New_Order
#[/binary_path]
#define VERSION _"dupa"
#enddef
[campaign]
name=_ "A New Order"
description= _ "The Version "+{VERSION}
end_text=
_"Basic test"
[/campaign]
The string _"A New Order" is extracted, the strings for description and end_text are not. This is a problem since I have a lot of places where I have macros in the form
{MESSAGE (Someone's Name) (portraits/profile_longname.png)
_"And now there is a text in second separate line"}
All those texts are missing, whenever I use manual exectuion of wmlxgettext from wesnoth 1.10 distribution, or makefiles fromthe WesCamp git. I must do seomthing wrong, since in previous pl.po which i downloaded from wescamp those strings are in place.

It's almost impossible to dig them all manually (there are too many of them). I am completely stuck now. All other problems except this one I have solved.
"Even when the Slav is gay the effort is often evident" -- P. R. RADOSAVLJEVICH
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: Generating po files manually - problems with msgmerge

Post by AI »

Spoiler:
Spoiler:
As you can see, it all works fine on my machine. (using wmlxgettext on latest trunk, which doesn't look like it has any platform-dependant parts)

I don't use *any* msg* tools here. I use make to do all that work (it also calls wmlxgettext for me). There might be platform-dependant stuff there, but I'll need a clearer view of what steps you're taking and what the results are.
szopen
Posts: 631
Joined: March 31st, 2005, 12:51 pm

Re: Generating po files manually - problems with msgmerge

Post by szopen »

Aaaaaand solved. With the moment I actually did "vi `which wmlxgettext`" and saw the line :

"
#WARNING! This file is basically a "proof of concept" and was meant as
# replacement for the perl script "utils/wmlxgettext". This script you
# are looking at is not used for the extraction of strings in Wesnoth mainline."

And everything because I did locate wmlxgettext and get the first location without wondering why there are two of them. Three nights and countless hours.

AI, I hope I have not took too much of your time.
"Even when the Slav is gay the effort is often evident" -- P. R. RADOSAVLJEVICH
Post Reply