0.9.1+ Changes to translating user campaigns in wesnoth
Moderator: Forum Moderators
-
- Inactive Developer
- Posts: 294
- Joined: March 30th, 2004, 4:45 pm
- Location: Nîmes, France
- Contact:
0.9.1+ Changes to translating user campaigns in wesnoth
Hi everybody,
The syntax to translate user campaigns has changed in 0.9.0 . Actually, it was broken in 0.9.0, and will be fixed in 0.9.1, thanks to Torangan who noticed this.
Before the change, to translated user campaigns, one had to add the "translations" and "textdomain" WML pseudo-variables in any element containing translatable text. For example, each scenario from Liberty was prefixed with:
This did bind the "wesnoth-Liberty" gettext-domain to data/campaigns/Liberty/translations, and made the strings below be translated in the wesnoth-Liberty domain.
Now, each scenario from Liberty must be prefixed with:
The #textdomain directive specifies that each translatable string, from now to the end of the current element (or the next #textdomain directive) will be in the wesnoth-Liberty domain.
And furthermore, the main campaign file, Liberty.cfg, must contain the following lines, which tell the engine where to find the translations for a given textdomain:
Edit: I was not explicit enough: [textdomain] is a new top-level WML element, not a child of [campaign].
Thus, [textdomain] must directly go at the root of the "Scenario.cfg" file, not inside the [campaign] tags.
Regards,
Ayin
The syntax to translate user campaigns has changed in 0.9.0 . Actually, it was broken in 0.9.0, and will be fixed in 0.9.1, thanks to Torangan who noticed this.
Before the change, to translated user campaigns, one had to add the "translations" and "textdomain" WML pseudo-variables in any element containing translatable text. For example, each scenario from Liberty was prefixed with:
Code: Select all
[scenario]
translations=data/campaigns/Liberty/translations
textdomain=wesnoth-Liberty
Now, each scenario from Liberty must be prefixed with:
Code: Select all
[scenario]
#textdomain wesnoth-Liberty
And furthermore, the main campaign file, Liberty.cfg, must contain the following lines, which tell the engine where to find the translations for a given textdomain:
Code: Select all
[textdomain]
name="wesnoth-Liberty"
path="data/campaigns/Liberty/translations"
[/textdomain]
Thus, [textdomain] must directly go at the root of the "Scenario.cfg" file, not inside the [campaign] tags.
Regards,
Ayin
Last edited by Ayin on April 24th, 2005, 8:00 pm, edited 1 time in total.
I would never talk to that person about boa constrictors, or primeval forests, or stars. I would bring myself down to his level. I would talk to him about bridge, and golf, and politics, and neckties. -- Antoine de Saint-Exupéry, in Le Petit Prince
Does that mean I am supposed to take the old code out?Ayin wrote:Now, each scenario from Liberty must be prefixed with:
In the [campaign] tag, or just the file?Ayin wrote:And furthermore, the main campaign file, Liberty.cfg, must contain the following lines
Also, is this acceptable for a path, or are my slashes wrong?
Code: Select all
path="/data/campaigns/Flight_Freedom/translations"
"ILLEGITIMIS NON CARBORUNDUM"
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
-
- Inactive Developer
- Posts: 294
- Joined: March 30th, 2004, 4:45 pm
- Location: Nîmes, France
- Contact:
Not necessarily, it won't break anything if you let it here.MadMax wrote:Does that mean I am supposed to take the old code out?Ayin wrote:Now, each scenario from Liberty must be prefixed with:
The slash before the strings should not be there, it should beMadMax wrote:In the [campaign] tag, or just the file?Ayin wrote:And furthermore, the main campaign file, Liberty.cfg, must contain the following lines
Also, is this acceptable for a path, or are my slashes wrong?
Code: Select all
path="/data/campaigns/Flight_Freedom/translations"
Code: Select all
path="data/campaigns/Flight_Freedom/translations"
every scenario or every element?Ayin wrote:Now, each scenario from Liberty must be prefixed with:
"ILLEGITIMIS NON CARBORUNDUM"
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Does the campaign.cfg file ALSO need
in addition to
to handle the translatable text in the file?
Code: Select all
#textdomain wesnoth-Liberty
Code: Select all
[textdomain]
name="wesnoth-Liberty"
path="data/campaigns/Liberty/translations"
[/textdomain]
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
-
- Inactive Developer
- Posts: 294
- Joined: March 30th, 2004, 4:45 pm
- Location: Nîmes, France
- Contact:
Yep. You need to:
* replace each "textdomain=" line by the equivalent "#textdomain" directive (you can have both, though, although the former will be ignored)
* add a textdomain declaration in your Campaign.cfg, like this:
* replace each "textdomain=" line by the equivalent "#textdomain" directive (you can have both, though, although the former will be ignored)
* add a textdomain declaration in your Campaign.cfg, like this:
Code: Select all
[textdomain]
name="wesnoth-Liberty"
path="data/campaigns/Liberty/translations"
[/textdomain]
-
- Inactive Developer
- Posts: 294
- Joined: March 30th, 2004, 4:45 pm
- Location: Nîmes, France
- Contact:
If the elements are set like that:MadMax wrote:every scenario or every element?Ayin wrote:Now, each scenario from Liberty must be prefixed with:
Code: Select all
[e1]
#textdomain blah
[e2]
value= _ "Translatable"
[/e2]
[/e1]
Example?
Code: Select all
[textdomain]
name="wesnoth-Liberty"
path="data/campaigns/Liberty/translations"
[/textdomain]
[campaign]
#textdomain wesnoth-Liberty
id=liberty
name= _ "Liberty"
define=CAMPAIGN_LIBERTY
... etc...
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
Does the #textdomain line have to be in the unit .cfgs too?
"ILLEGITIMIS NON CARBORUNDUM"
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Father of Flight to Freedom
http://www.wesnoth.org/wiki/FlightToFreedom
Yes. However, the argument of the #textdomain command can be wesnoth or wesnoth-yourdomain.
For example, I have modified skeletons and revenants but their text (name, description, and weapon name) is unchanged, so they have #textdomain wesnoth.
I have modified L2 outlaws with modified text, so they are in #textdomain wesnoth-Liberty. All the custom units have #textdomain wesnoth-Liberty.
For example, I have modified skeletons and revenants but their text (name, description, and weapon name) is unchanged, so they have #textdomain wesnoth.
I have modified L2 outlaws with modified text, so they are in #textdomain wesnoth-Liberty. All the custom units have #textdomain wesnoth-Liberty.
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
More changes
I just committed support to extract messages belonging to several domains from a single .cfg file. Beware, it has side-effects that may require updates to some of your campaign files.
The disrupting change is that the #textdomain tags also has to be added in cfg files included from the scenarios (files like utils.cfg or deaths.cfg in the official campaigns).
As explained in the commit message, think about your files being included by another campaign instead: the messages must be looked for in the correct domain in this case too. That is, if I understand well the current implementation, where the scope of #textdomain is the enclosing WML block, you must for example add #textdomain tags in the relevant wml blocks of the each macro (assuming each macro with a translatable string has a wml block). Look at those files in CVS as an example.
The benefit is that you can now switch a block to the wesnoth textdomain, to avoid duplicating standard translations in your own domain. Be aware of a limitation of the current implementation: the wmlxgettext string extractor does not know the scope of the #textdomain directive yet, so if you use this feature, you must add a #textdomain after your block, as follows:
The disrupting change is that the #textdomain tags also has to be added in cfg files included from the scenarios (files like utils.cfg or deaths.cfg in the official campaigns).
As explained in the commit message, think about your files being included by another campaign instead: the messages must be looked for in the correct domain in this case too. That is, if I understand well the current implementation, where the scope of #textdomain is the enclosing WML block, you must for example add #textdomain tags in the relevant wml blocks of the each macro (assuming each macro with a translatable string has a wml block). Look at those files in CVS as an example.
The benefit is that you can now switch a block to the wesnoth textdomain, to avoid duplicating standard translations in your own domain. Be aware of a limitation of the current implementation: the wmlxgettext string extractor does not know the scope of the #textdomain directive yet, so if you use this feature, you must add a #textdomain after your block, as follows:
Code: Select all
#textdomain wesnoth-foo
my=_"text"
[unit]
#textdomain wesnoth
description=_"standard text"
[/unit]
#textdomain wesnoth-foo
other=_"without the above directive, this text would be extracted as if in wesnoth domain instead, altough it will be searched in wesnoth-foo at runtime"
gettextization
french l10n team member
french l10n team member
#textdomain directives are no longer WML-scoped. See http://www.wesnoth.org/forum/viewtopic.php?t=5838 for additional details.
-
- Posts: 837
- Joined: April 14th, 2005, 4:17 am