Stringtable.xml: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Page refresh)
m (Text replacement - "|size=0.75" to "|size= 0.75")
(33 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{SideTOC}}
{{TOC|side}}
{{Informative | [[Stringtable.xml]] was introduced with {{arma}}. For {{ofp}}, see [[Stringtable.csv]].}}
{{Feature | Informative | [[Stringtable.xml]] was introduced with {{arma1}}. For {{ofp}}, see [[Stringtable.csv]].}}
String tables are used to make internationalization easier for the game. They are used in addons, missions, and scripts, and are located in the root of the mission or addon folders.
String tables are used to make internationalization easier for the game. They are used in addons, missions, and scripts, and are located in the root of the mission or addon folders.


Line 8: Line 8:
== Stringtable Editors ==
== Stringtable Editors ==


It strongly recommended to use a tool to edit the XML file; a selection of Stringtable [[:Category:Community Tools|Community Tools]] can be found in the [[:Category:Community Tools#Localisation Tools|Community Tools - Localisation Tools]] page section.
It is strongly recommended to use a tool to edit the XML file; a selection of Stringtable [[:Category:Community Tools|Community Tools]] can be found in the [[:Category:Community Tools#Localisation Tools|Community Tools - Localisation Tools]] page section.




Line 20: Line 20:
<Package name="Mission One">
<Package name="Mission One">
<Container name="Some Words">
<Container name="Some Words">
<Key ID="str_TAG_Yes">
<Key ID="STR_TAG_Yes">
<Original>yes</Original>
<Original>yes</Original>
<English>yes</English>
<English>yes</English>
Line 33: Line 33:
<Korean>네</Korean>
<Korean>네</Korean>
<Japanese>はい</Japanese>
<Japanese>はい</Japanese>
                <Chinesesimp>是</Chinesesimp>
<Chinesesimp>是</Chinesesimp>
                <Chinese>是(繁體)</Chinese>
<Chinese>是(繁體)</Chinese>
</Key>
</Key>
<Key ID="str_TAG_No">
<Key ID="STR_TAG_No">
<Original>no</Original>
<Original>no</Original>
</Key>
</Key>
</Container>
</Container>
<Container name="Another Container">
<Container name="Another Container">
<Key ID="str_TAG_formatted">
<Key ID="STR_TAG_formatted">
<Original>Hello, %1.</Original>
<Original>Hello, %1.</Original>
</Key>
</Key>
<Key ID="str_TAG_structuredText">
<Key ID="STR_TAG_structuredText">
<Original>Some text &lt;t color='%1'&gt;%2&lt;/t&gt;</Original>
<Original>Some text &lt;t color='%1'&gt;%2&lt;/t&gt;</Original>
</Key>
</Key>
Line 53: Line 53:
</spoiler>
</spoiler>


{{Informative | Package and container names are only for organisational use; use them for your own sanity.}}
{{Feature | Informative | {{hl|Package}} and {{hl|Container}} "groups" are only helpful for organisation and have no impact on the translations; use them for your own sanity.}}
{{Important | [[Stringtable.xml]] must be saved with '''UTF-8 Encoding''' for international characters to display and save correctly.}}
{{Feature | important | [[Stringtable.xml]] must be saved with '''UTF-8 Encoding''' for international characters to display and save correctly.}}




== Supported languages ==
== Supported languages ==
{|
! {{arma2}} &amp; {{arma2oa}}
! {{arma3}}
|-
| style="vertical-align: top" |


{| class="wikitable"
{| class="wikitable"
! {{arma2}} &amp; {{arma2oa}} !! {{arma3}}
! className
! In-game name
! Note
|-
| English
| '''English'''
|
|-
| Czech
| '''Čeština'''
|
|-
| French
| '''Français'''
|
|-
| Spanish
| '''Español'''
|
|-
| Italian
| '''Italiano'''
|
|-
| Polish
| '''Polski'''
|
|-
| Russian
| '''Русский'''
|
|-
| German
| '''Deutsch'''
|
|-
| Hungarian
| '''Magyar'''
| Partially supported
|-
|-
| Portuguese
| '''Portuguese'''
| Not available in-game
|}
| style="vertical-align: top" |
| style="vertical-align: top" |
* English
 
* Czech
{| class="wikitable"
* French
! className
* Spanish
! In-game name
* Italian
! Note
* Polish
|-
* Russian
| English
* German
| '''English'''
|
|-
| Czech
| '''Čeština'''
|
|-
| French
| '''Français'''
|
|-
| Spanish
| '''Español'''
|
|-
| Italian
| '''Italiano'''
|
|-
| Polish
| '''Polski'''
|
|-
| Portuguese
| '''Português do Brasil'''
|
|-
| Russian
| '''Русский'''
|
|-
| German
| '''Deutsch'''
|
|-
| Korean
| '''한국어'''
|
|-
| Japanese
| '''日本語'''
|
|-
| Chinese
| '''繁體中文'''
| Chinese Traditional
|-
| Chinesesimp
| '''简体中文'''
| Chinese Simplified
|-
| Turkish
| '''Türkçe'''
|
|
<div style="column-count: 3">
|-
* English
| Swedish
* Czech
| {{n/a}}
* French
| rowspan="9" | Cannot be set in-game.<br>Edit '''arma3.cfg''' to use that language.
* Spanish
|-
* Italian
| Slovak
* Polish
| {{n/a}}
* Portuguese
|-
* Russian
| SerboCroatian
* German
| {{n/a}}
* Korean (region exclusive)
|-
* Japanese (region exclusive)
| Norwegian
* Chinese 繁體中文 (Chinese Traditional)
| {{n/a}}
* Chinesesimp 简体中文 (Chinese Simplified)
|-
* Turkish
| Icelandic
* Swedish
| {{n/a}}
* Slovak
|-
* SerboCroatian
| Hungarian
* Norwegian
| '''Magyar'''
* Icelandic
|-
* Hungarian
| Greek
* Greek
| {{n/a}}
* Finnish
|-
* Dutch
| Finnish
</div>
| {{n/a}}
|-
| Dutch
| {{n/a}}
|}
 
|}
|}


=== Unsupported language English in stringtable ===
See [[Crash_Files#Common_Errors_and_Warnings|Common Errors and Warnings]].


== Key naming convention ==
== Key naming convention ==


{{Informative | Same as [[Identifier#Recommendations|global variables]], it is recommended to use a '''{{Color|purple|TAG}}''' to prevent translation collision with mods.}}
Same as [[Identifier#Recommendations|global variables]], it is recommended to use a '''{{Color|purple|TAG}}''' to prevent translation collision between mods (e.g {{hl|STR_{{Color|purple|TAG}}_helloThere}}).
 
If the key is to be used by [[Config]] ([[Description.ext]] and dialogs included), it '''must''' start with <tt>STR</tt> (or <tt>str</tt>, casing does not matter). '''By convention''' however, <tt>STR_</tt> is the norm for all the entries.




Line 110: Line 216:


Strings stored in the stringtable can be in the following formats:
Strings stored in the stringtable can be in the following formats:
* Normal text, such as <tt>Hello there</tt>
* Normal text, such as {{hl|Hello there}}
* [[format]] text, such as <tt>Hello %1</tt>
* [[format]] text, such as {{hl|Hello %1}}
* [[Structured Text]], such as <tt><t size='2'>Hello</t> there</tt>, '''but''':<br><!--
* [[Structured Text]], such as {{hl|c= <t size='2'>Hello</t> there}}, '''but''':<br><!--
-->{{Important | The HTML tag characters <tt>&lt;</tt> and <tt>&gt;</tt> must respectively be encoded as <tt>&amp;lt;</tt> and <tt>&amp;gt;</tt>.}}<!--
-->{{Feature | important | The HTML tag characters {{hl|&lt;}} and {{hl|&gt;}} must respectively be encoded as {{hl|&amp;lt;}} and {{hl|&amp;gt;}}.}}<!--
--><tt><t size='2'>Hello</t> there</tt> would then become <tt>&amp;lt;t size='2'&amp;gt;Hello&amp;lt;/t&amp;gt; there</tt>.
-->{{hl|c= <t size='2'>Hello</t> there}} would then become {{hl|c= &amp;lt;t size='2'&amp;gt;Hello&amp;lt;/t&amp;gt; there}}.




Line 122: Line 228:


A translation can be retrieved and used in a script by using the [[localize]] command:
A translation can be retrieved and used in a script by using the [[localize]] command:
 
<sqf>
[[hint]] [[localize]] "str_TAG_Yes"; {{cc|returns "Yes" in English, "Oui" in French, etc.}}
hint localize "STR_TAG_Yes"; // returns "Yes" in English, "Oui" in French, etc.
[[hint]] [[format]] [<nowiki/>[[localize]] "str_TAG_formatted", [[name]] [[player]]];
hint format [localize "STR_TAG_formatted", name player];
[[hint]] [[localize]] "str_TAG_structuredText";
hint localize "str_TAG_structuredText"; // casing in scripting does not matter
</sqf>


=== Config ===
=== Config ===


Whether it is in [[Description.ext]], [[Campaign Description.ext]], Dialogs etc., the [[Config]] syntax to refer to a Stringtable translation is as follow (here, a [[Description.ext]] example):
Whether it is in [[Description.ext]], [[Campaign Description.ext]], Dialogs etc., a translated [[Config]] entry '''must''' use the {{hl|$}} prefix (to an '''uppercase''' {{hl|STR}}) for the engine to look the translation key up:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
onLoadName = $STR_TAG_missionName;
onLoadName = "$STR_TAG_missionName";
onLoadMission = $STR_TAG_loadMissionText;
onLoadMission = $STR_TAG_loadMissionText; // works without quotes too - not recommended
overviewText = $STR_TAG_overviewText;
overviewText = "$str_TAG_overviewText"; // invalid, will return "$str_TAG_overviewImage" (with $ sign)
overviewPicture = $STR_TAG_overviewImage;
</syntaxhighlight>
</syntaxhighlight>


The preprocessor will replace <tt>$STR</tt> entries with the Stringtable values.
The preprocessor will replace {{hl|$STR}} entries with their corresponding Stringtable value.
 
=== Editor ===
 
In markers and other [[Eden Editor]] fields (e.g Mission Name), translation keys should be prefixed with {{hl|@}}, without any quotes around - e.g {{hl|@STR_myMarkerName}}. Casing does not matter here either.




== Multiplayer ==
== Multiplayer ==


[[Multiplayer Scripting]] should consider that the translation implementation ''should'' ideally happen client-side; clients and server are likely to be configured in a different language, as a server-side call to [[:Category:Commands with global effects|global effect]] text commands (such as [[setMarkerText]]) would set the text in the server's language to everyone.
[[Multiplayer Scripting]] should consider that the translation implementation ''should'' ideally happen client-side; clients and server are likely to be configured in a different language, as a server-side call to [[Multiplayer Scripting#Locality|global effect]] text commands (such as [[setMarkerText]]) would set the text in the server's language to everyone.


Example of client-side translation of a server message:
Example of client-side translation of a server message:
<sqf>
// Server-side
if (isServer) then
{
[nil, nil, rHINT, localize "STR_TAG_myMessage"] call RE; // Arma 2 - server language
[nil, nil, rSPAWN, { hint localize "STR_TAG_myMessage" }] call RE; // Arma 2 - client language
["STR_TAG_myMessage"] remoteExecCall ["TAG_fnc_localHint"]; // Arma 3
};


{{cc|Server-side}}
// Client-side executed function
[[if]] ([[isServer]]) [[then]]
TAG_fnc_localHint = {
{
if (hasInterface) then
[<nowiki/>[[nil]], [[nil]], rHINT, [[localize]] "str_TAG_myMessage"] [[call]] [[RE]]; {{cc|{{arma2}}}}
{
["str_TAG_myMessage"] [[remoteExecCall]] ["TAG_fnc_localHint"]; {{cc|{{arma3}}}}
// hintSilent parseText (localize _this); // Arma 2
};
hintSilent parseText (_this call BIS_fnc_localize); // Arma 3
};
{{cc|Client-side executed function}}
};
TAG_fnc_localHint = {
</sqf>
[[if]] ([[hasInterface]]) [[then]]
{
[[hintSilent]] [[parseText]] ([[localize]] [[_this]]); {{cc|{{arma2}}}}
[[hintSilent]] [[parseText]] ([[_this]] [[call]] [[BIS_fnc_localize]]); {{cc|{{arma3}}}}
};
};




== See also ==
== Commands & Functions ==


* localize
* [[localize]]
* isLocalized
* {{GVI|arma3|0.50|size= 0.75}} [[isLocalized]]
* [[BIS_fnc_localize]] (since {{arma3}})
* {{GVI|arma3|1.00|size= 0.75}} [[BIS_fnc_localize]]
* {{GVI|arma3|2.02|size= 0.75}} [[getTextRaw]]




[[Category:BIS File Formats]]
[[Category:BIS File Formats]]
[[Category:Arma 3: Editing]]
{{GameCategory|arma1|Editing}}
{{GameCategory|arma2|Editing}}
{{GameCategory|arma3|Editing}}

Revision as of 13:09, 21 December 2022

Stringtable.xml was introduced with Armed Assault. For Operation Flashpoint, see Stringtable.csv.

String tables are used to make internationalization easier for the game. They are used in addons, missions, and scripts, and are located in the root of the mission or addon folders.

Any strings that are used in the game can be kept separate from the code, and can therefore easily be edited and expanded into different languages. Instead of using strings directly in the code, you are using a variable. This variable will then contain the actual string, read from stringtable.xml, with the language that is being read depending on the game settings.


Stringtable Editors

It is strongly recommended to use a tool to edit the XML file; a selection of Stringtable Community Tools can be found in the Community Tools - Localisation Tools page section.


Example

<?xml version="1.0" encoding="utf-8" ?>
<Project name="Any Name">
	<Package name="Mission One">
		<Container name="Some Words">
			<Key ID="STR_TAG_Yes">
				<Original>yes</Original>
				<English>yes</English>
				<Czech>ano</Czech>
				<French>oui</French>
				<German>ja</German>
				<Italian></Italian>
				<Polish>tak</Polish>
				<Portuguese>sim</Portuguese>
				<Russian>да</Russian>
				<Spanish></Spanish>
				<Korean></Korean>
				<Japanese>はい</Japanese>
				<Chinesesimp></Chinesesimp>
				<Chinese>是(繁體)</Chinese>
			</Key>
			<Key ID="STR_TAG_No">
				<Original>no</Original>
			</Key>
		</Container>
		<Container name="Another Container">
			<Key ID="STR_TAG_formatted">
				<Original>Hello, %1.</Original>
			</Key>
			<Key ID="STR_TAG_structuredText">
				<Original>Some text &lt;t color='%1'&gt;%2&lt;/t&gt;</Original>
			</Key>
		</Container>
	</Package>
</Project>
↑ Back to spoiler's top

Package and Container "groups" are only helpful for organisation and have no impact on the translations; use them for your own sanity.
Stringtable.xml must be saved with UTF-8 Encoding for international characters to display and save correctly.


Supported languages

Arma 2 & Arma 2: Operation Arrowhead Arma 3
className In-game name Note
English English
Czech Čeština
French Français
Spanish Español
Italian Italiano
Polish Polski
Russian Русский
German Deutsch
Hungarian Magyar Partially supported
Portuguese Portuguese Not available in-game
className In-game name Note
English English
Czech Čeština
French Français
Spanish Español
Italian Italiano
Polish Polski
Portuguese Português do Brasil
Russian Русский
German Deutsch
Korean 한국어
Japanese 日本語
Chinese 繁體中文 Chinese Traditional
Chinesesimp 简体中文 Chinese Simplified
Turkish Türkçe
Swedish N/A Cannot be set in-game.
Edit arma3.cfg to use that language.
Slovak N/A
SerboCroatian N/A
Norwegian N/A
Icelandic N/A
Hungarian Magyar
Greek N/A
Finnish N/A
Dutch N/A

Unsupported language English in stringtable

See Common Errors and Warnings.

Key naming convention

Same as global variables, it is recommended to use a TAG to prevent translation collision between mods (e.g STR_TAG_helloThere).


String Formats

Strings stored in the stringtable can be in the following formats:

  • Normal text, such as Hello there
  • format text, such as Hello %1
  • Structured Text, such as <t size='2'>Hello</t> there, but:
    The HTML tag characters < and > must respectively be encoded as &lt; and &gt;.
    <t size='2'>Hello</t> there would then become &lt;t size='2'&gt;Hello&lt;/t&gt; there.


Usage

Script

A translation can be retrieved and used in a script by using the localize command:

hint localize "STR_TAG_Yes"; // returns "Yes" in English, "Oui" in French, etc. hint format [localize "STR_TAG_formatted", name player]; hint localize "str_TAG_structuredText"; // casing in scripting does not matter

Config

Whether it is in Description.ext, Campaign Description.ext, Dialogs etc., a translated Config entry must use the $ prefix (to an uppercase STR) for the engine to look the translation key up:

onLoadName = "$STR_TAG_missionName";
onLoadMission = $STR_TAG_loadMissionText;	// works without quotes too - not recommended
overviewText = "$str_TAG_overviewText";		// invalid, will return "$str_TAG_overviewImage" (with $ sign)

The preprocessor will replace $STR entries with their corresponding Stringtable value.

Editor

In markers and other Eden Editor fields (e.g Mission Name), translation keys should be prefixed with @, without any quotes around - e.g @STR_myMarkerName. Casing does not matter here either.


Multiplayer

Multiplayer Scripting should consider that the translation implementation should ideally happen client-side; clients and server are likely to be configured in a different language, as a server-side call to global effect text commands (such as setMarkerText) would set the text in the server's language to everyone.

Example of client-side translation of a server message:

// Server-side if (isServer) then { [nil, nil, rHINT, localize "STR_TAG_myMessage"] call RE; // Arma 2 - server language [nil, nil, rSPAWN, { hint localize "STR_TAG_myMessage" }] call RE; // Arma 2 - client language ["STR_TAG_myMessage"] remoteExecCall ["TAG_fnc_localHint"]; // Arma 3 }; // Client-side executed function TAG_fnc_localHint = { if (hasInterface) then { // hintSilent parseText (localize _this); // Arma 2 hintSilent parseText (_this call BIS_fnc_localize); // Arma 3 }; };


Commands & Functions