How to create a .po file?

Discussion and development of scenarios and campaigns for the game.

Moderator: Forum Moderators

Post Reply
User avatar
Nobun
Code Contributor
Posts: 129
Joined: May 4th, 2009, 9:28 pm
Location: Italy

How to create a .po file?

Post by Nobun »

I'm trying to do a campaign. The main language is, obliouvsly, english (even if it is a bad english becouse I don't know english very well) but I'd like also to write storyline (so translate) in my own native language (Italian).

So, seeing the fact I'd like to create at least an Italian translation, I need to create a .po file. My question is... I don't think that .po files in mainline are created manually (seeing comments it seems that some of them are created with KBabel). I have poedit (under windows). The problem is... how to make a .po file for campaign and update it everytime?
All documentations I see are about how to make a translation with an ALREADY EXISTING po or how to update your po with a new po file you find in SVN (so, again, using an ALREADY EXISTING po). But there aren't any explaination how to create a po from scratch

Moreover... I tried to read some instructions also outside wesnoth (I was unable to find any usefull help in wesnoth site or forums) and I tried to apply the methods I read using google. But, all times I tried to create a new .po, an error message always appeared in poedit, and the .po file created resulted, more or less, blank (except some initial informations, but no one line-to-translate found in that file)

And, after that, how to create a new po, in the following steps, without losing translations previously made? (I am developing this campaign in this way: I create 2-3 scenarios than I upload to an Italian forum. And than again for the next 2-3 scenarios and so on)

Note: I don't know if I really finish to develop this campaign. My main target is to learn something about WML and creation of campaign trying a sort of a direct approach.
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: How to create a .po file?

Post by AI »

The usual way to do this:
-Ensure all your cfg files have their textdomain set correctly (for an addon located at ~addons/foo_bar, the textdomain would be wesnoth-foo_bar)
-Set translate=true in your pbl file
-Upload your campaign to the add-on server
-Wait a few days while some non-automated tasks are done (alternatively, poke torangan on irc)
-Go to berlios and locate your campaign (probably somewhere in branches/1.8 or trunk), there should be PO files in there that will be updated when translators submit new versions of their translations
User avatar
Nobun
Code Contributor
Posts: 129
Joined: May 4th, 2009, 9:28 pm
Location: Italy

Re: How to create a .po file?

Post by Nobun »

Thank for your answer. However there is a thing I don't understand compleately (perhaps becouse of my limited english). When you say "Wait a few days while some non-automated tasks are done"... do you mean that you developers have to work to create .po for us? :hmm:

I'd like more to create it by myself without forcing you to do extra-job, also considering the fact I'm not sure that this campaign will reach an end, and it is in development (gamma version = more beta than a beta xD)... so perhaps could be a useless work for you (I mean... the campaign is not really enjoyable by players in this momentand I don't know if I finish it... if you work now it could be a useless spent of time for you... I'd like to avoid to push you to spend your precious time in this moment)
torangan
Retired Developer
Posts: 1365
Joined: March 27th, 2004, 12:25 am
Location: Germany

Re: How to create a .po file?

Post by torangan »

If you're not sure that your campaign will stay, don't try to attract translators. They will loose way more time then developers for creating the .po files.
WesCamp-i18n - Translations for User Campaigns:
http://www.wesnoth.org/wiki/WesCamp

Translators for all languages required: contact me. No geek skills required!
User avatar
Nobun
Code Contributor
Posts: 129
Joined: May 4th, 2009, 9:28 pm
Location: Italy

Re: How to create a .po file?

Post by Nobun »

I totally agree with you. Infact I asked about how to create po only becouse I'd like to write by myself both english and Italian language (so write by myself the po for Italian). I'm not trying to attract translators to my project in this moment. Only if this campaign will see an end and only if will be appear at last a decent one I will upload it and try to see if someone is interested on improving it with suggestions and translations
But not in this moment... it is too early
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: How to create a .po file?

Post by AI »

After setting the textdomains, you can get a .pot (po template) file by invoking wmlxgettext in a complicated way. I don't have a computer nearby, so a better explanation will have to wait until tomorrow.
User avatar
Nobun
Code Contributor
Posts: 129
Joined: May 4th, 2009, 9:28 pm
Location: Italy

Re: How to create a .po file?

Post by Nobun »

Thank a lot, AI.
When you have time, please explain me, I'm curious.

---

However... I decided, in the meantime, to make by myself a simple application that creates a po skele for a wesnoth addon

the po created have the following things:

1)

comments:
in comments are reported file(s) and row(s) of every entry, but not the type of addon and id

so

if an "official" po appears like this

#: [campaign] id=your_id
#. add-ons/your_campaign/file.cfg:xx
#. add-ons/your_campaign/file2.cfg:xx
msgid = "value"
msgstr = ""

my po appear the same except that the first line (#: [campaign] id=your_id) not present

2)
Order:

the file order don't follow a particular order. Cfg files are simply find recursively into addon dir and subdirs. so, for example, it is possible that the strings of the 3rd scenarios are putted before the strings of the 1st one

3)
The program I did is really simple to use: browse for addon folder and push a button: a new "skele.po" created in addon dir
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: How to create a .po file?

Post by AI »

I forgot all about this thread, but here's how to run wmlxgettext anyway:

Code: Select all

utils/wmlxgettext --directory=. --domain=wesnoth-Your_Campaigns_textdomain all.cfg of.cfg the.cfg files.cfg that.cfg you.cfg want.cfg to.cfg extract/translatable/strings.cfg out/of.cfg > Your_Campaigns_po_template.pot
Your program sounds good enough, could you attach it? wmlxgettext isn't the best-looking perl around.
Dindoz
Posts: 17
Joined: February 25th, 2014, 1:50 pm

Re: How to create a .po file?

Post by Dindoz »

AI wrote: -Go to berlios and locate your campaign (probably somewhere in branches/1.8 or trunk), there should be PO files in there that will be updated when translators submit new versions of their translations
Apparently this is usless snce 2011 so I m trying to create a .po file with poedit

Code: Select all

xgettext --language=wml --force-po -o %o %C %K %F
wml is unknow for the parser. I tryed with C or php but I got an error or nothing.

which parser do you use ?

maybe my error is from my keyword I use only one atm :

Code: Select all

_
I have tryed the method from AI in terminal but I fail each time ^"
Computer : Clevo w310cz Os : Ubuntu 13.10 TBoW : 11.11.11
Sorry for my poor english I do my best.
Dindoz
Posts: 17
Joined: February 25th, 2014, 1:50 pm

Re: How to create a .po file?

Post by Dindoz »

I found the language who made almost correctly a .po its Perl :)

Code: Select all

xgettext --language=Perl --force-po -o %o %C %K %F

EDIT :
Something is strange

Code: Select all

[campaign]
	id=The_Forgotten_Hero
	first_scenario=01_Ambush
	define=The_Forgotten_Hero 
	difficulties=EASY,NORMAL,HARD #idef HARD #else #endif 
	image=data/add-ons/The_Forgotten_Hero/images/campaign_image.png 
	icon=data/add-ons/The_Forgotten_Hero/images/campaign_icon.png 
	difficulty_descriptions= _ "&units/undead-necromancers/adept-magic-3.png=(Marchamalo mod's) Facile;&units/undead-necromancers/dark-sorcerer-attack-staff-2.png=(Burning style) Moyen;&units/undead-necromancers/ancient-lich-magic-3.png=(Master of Puppets) Hardcore"
	description= _ "Mal-Ravanal traverse les méandres des vortex spacio-temporel pour modifier le passé d'Haldric afin d'anniyler toute forme de vie"
	name= _ "Le Héros Oublié"
	abbrev= _ "LHO" 
[/campaign]
With this code name all string with _ for prefix are right in the .po but with the code bellow : name,abbrev et difficulty_description arent in the .po

Code: Select all

[campaign]
	id=The_Forgotten_Hero
	name= _ "Le Héros Oublié"
	abbrev= _ "LHO" 
	define=The_Forgotten_Hero 
	difficulties=EASY,NORMAL,HARD #idef HARD #else #endif 
	difficulty_descriptions= _ "&units/undead-necromancers/adept-magic-3.png=(Marchamalo mod's) Facile;&units/undead-necromancers/dark-sorcerer-attack-staff-2.png=(Burning style) Moyen;&units/undead-necromancers/ancient-lich-magic-3.png=(Master of Puppets) Hardcore"
	image=data/add-ons/The_Forgotten_Hero/images/campaign_image.png 
	icon=data/add-ons/The_Forgotten_Hero/images/campaign_icon.png 
	description= _ "Mal-Ravanal traverse les méandres des vortex spacio-temporel pour modifier le passé d'Haldric afin d'anniyler toute forme de vie"
	first_scenario=01_Ambush
[/campaign]
Computer : Clevo w310cz Os : Ubuntu 13.10 TBoW : 11.11.11
Sorry for my poor english I do my best.
Post Reply