Difference between revisions of "Translatable"

From The Battle for Wesnoth Wiki
m (categorizing)
(Explanation: Correct examples, add syntax highlighting, remove extraneous "how to use your browser")
Line 2: Line 2:
  
 
Items marked with the text {{Translatable}} are WML strings that can be translated. Nearly every string that the player sees can be translated. A program called "gettext" automatically parses your WML files, seeks out strings marked as translatable, and compiles them into a translation template file. Translators can then use this file to create translations of the game into their languages.
 
Items marked with the text {{Translatable}} are WML strings that can be translated. Nearly every string that the player sees can be translated. A program called "gettext" automatically parses your WML files, seeks out strings marked as translatable, and compiles them into a translation template file. Translators can then use this file to create translations of the game into their languages.
 
-----
 
 
Please hit 'back' on your browser to return to the page you were reading or continue for examples.
 
 
-----
 
  
 
You, the scenario writer, must mark a string as translatable by including an underscore character "_" before the string starts. Here is an example.
 
You, the scenario writer, must mark a string as translatable by including an underscore character "_" before the string starts. Here is an example.
Line 18: Line 12:
 
When using strings in macros, include the underscore character with the actual text. Gettext does not know how to perform macro or variable substitution, so always keep the underscore with the string it marks.
 
When using strings in macros, include the underscore character with the actual text. Gettext does not know how to perform macro or variable substitution, so always keep the underscore with the string it marks.
  
Bad:
+
Bad:
{VARIABLE message_text ("Hello, fair warrior!")}
+
<syntax_highlight lang='wml'>
[message]
+
{VARIABLE message_text ("Hello, fair warrior!")}
message= _ $message_text
+
[message]
[/message]
+
message= _ {message_text}
 +
[/message]
 +
</syntaxhighlight>
  
Good:
+
Good:
{VARIABLE message_text ( _ "Hello, fair warrior!")}
+
<syntax_highlight lang='wml'>
[message]
+
{VARIABLE message_text ( _ "Hello, fair warrior!")}
message=$message_text
+
[message]
[/message]
+
message={message_text}
 +
[/message]
 +
</syntaxhighlight>
  
 
== See Also ==
 
== See Also ==

Revision as of 17:37, 1 August 2016

Explanation

Items marked with the text (translatable) are WML strings that can be translated. Nearly every string that the player sees can be translated. A program called "gettext" automatically parses your WML files, seeks out strings marked as translatable, and compiles them into a translation template file. Translators can then use this file to create translations of the game into their languages.

You, the scenario writer, must mark a string as translatable by including an underscore character "_" before the string starts. Here is an example.

Not translatable:
description="Baldras"
Translatable:
description= _ "Baldras"

When using strings in macros, include the underscore character with the actual text. Gettext does not know how to perform macro or variable substitution, so always keep the underscore with the string it marks.

Bad: <syntax_highlight lang='wml'> {VARIABLE message_text ("Hello, fair warrior!")} [message] message= _ {message_text} [/message] </syntaxhighlight>

Good: <syntax_highlight lang='wml'> {VARIABLE message_text ( _ "Hello, fair warrior!")} [message] message={message_text} [/message] </syntaxhighlight>

See Also