Stringtable.xml: Difference between revisions
m (→Multiplayer: change to Template:Informative) |
m (→Config: removed hl in comment) |
||
(63 intermediate revisions by 12 users not shown) | |||
Line 1: | Line 1: | ||
{{TOC|side}} | |||
{{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. | ||
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 | 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 [[:Category:Community Tools|Community Tools]] can be found in the [[:Category:Community Tools#Localisation Tools|Community Tools - Localisation Tools]] page section. | |||
== Example == | |||
<spoiler text="Show Stringtable.xml example"> | |||
<syntaxhighlight lang="xml"> | |||
<?xml version="1.0" encoding="utf-8" ?> | |||
<Project name="Any Name"> | <Project name="Any Name"> | ||
<Package name="Mission One"> | <Package name="Mission One"> | ||
<Container name="Some Words"> | <Container name="Some Words"> | ||
<Key ID=" | <Key ID="STR_TAG_Yes"> | ||
<Original>yes</Original> | <Original>yes</Original> | ||
<English>yes</English> | <English>yes</English> | ||
Line 20: | Line 31: | ||
<Russian>да</Russian> | <Russian>да</Russian> | ||
<Spanish>sí</Spanish> | <Spanish>sí</Spanish> | ||
<Korean>네</Korean> | |||
<Japanese>はい</Japanese> | |||
<Chinesesimp>是</Chinesesimp> | |||
<Chinese>是(繁體)</Chinese> | |||
</Key> | </Key> | ||
<Key ID=" | <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=" | <Key ID="STR_TAG_formatted"> | ||
<Original>Hello, %1.</Original> | <Original>Hello, %1.</Original> | ||
</Key> | </Key> | ||
<Key ID=" | <Key ID="STR_TAG_structuredText"> | ||
<Original>Some text & | <Original>Some text <t color='%1'>%2</t></Original> | ||
</Key> | </Key> | ||
</Container> | </Container> | ||
</Package> | </Package> | ||
</Project> | </Project> | ||
</ | </syntaxhighlight> | ||
</spoiler> | |||
{{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.}} | |||
{{Feature|important|[[Stringtable.xml]] must be saved with '''UTF-8 Encoding''' for international characters to display and save correctly.}} | |||
== Supported Languages == | |||
{| | |||
! {{arma2}} & {{arma2oa}} | |||
! {{arma3}} | |||
|- | |||
| style="vertical-align: top" | | |||
{| class="wikitable" | |||
! 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" | | |||
= | {| class="wikitable" | ||
= | ! 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}} | |||
| rowspan="9" | Cannot be set in-game.<br>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 [[Crash_Files#Common_Errors_and_Warnings|Common Errors and Warnings]]. | |||
== Key Naming Convention == | |||
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}}). | |||
==== | == String Formats == | ||
< | Strings stored in the stringtable can be in the following formats: | ||
* Normal text, such as {{hl|Hello there}} | |||
* [[format]] text, such as {{hl|Hello %1}} | |||
* [[Structured Text]], such as {{hl|c= <t size='2'>Hello</t> there}}, '''but''':<br><!-- | |||
-->{{Feature | important | The HTML tag characters {{hl|<}} and {{hl|>}} must respectively be encoded as {{hl|&lt;}} and {{hl|&gt;}}.}}<!-- | |||
-->{{hl|c= <t size='2'>Hello</t> there}} would then become {{hl|c= &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: | |||
<sqf> | |||
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 | |||
</sqf> | |||
==== | === Config === | ||
< | 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"> | |||
onLoadName = "$STR_TAG_missionName"; | |||
overviewText = "$str_TAG_overviewText"; // invalid, will display "$str_TAG_overviewText" (with the $ sign) | |||
onLoadMission = $STR_TAG_loadMissionText; // works without quotes but this is NOT recommended | |||
</syntaxhighlight> | |||
The preprocessor will replace {{hl|$STR}} entries with their corresponding Stringtable value. | |||
==== Translated Sounds ==== | |||
The Stringtable can be used to use different voices depending on the user's language setting: | |||
<syntaxhighlight lang="cpp"> | |||
class CfgRadio | |||
{ | { | ||
class TAG_V01 | |||
class | |||
{ | { | ||
name = ""; | name = "$STR_TAG_V01_name"; | ||
sound[] = {$ | sound[] = { "$STR_TAG_V01_path", 1, 1 }; | ||
title = $ | title = "$STR_TAG_V01_subtitle"; | ||
}; | }; | ||
}; | }; | ||
// | </syntaxhighlight> | ||
the Stringtable's entries looking like this: | |||
/ | <syntaxhighlight lang="xml"> | ||
</ | <Key ID="STR_V01_name"> | ||
<English>"Hello There" by OWK</English> | |||
<French>"Salut à tous" par OWK</French> | |||
</Key> | |||
<Key ID="STR_V01_path"> | |||
<English>Sound\EN\v01.ogg</English> | |||
<French>Sound\FR\v01.ogg</French> | |||
</Key> | |||
<Key ID="STR_V01_subtitle"> | |||
<English>Hello There!</English> | |||
<French>Salut à tous !</French> | |||
</Key> | |||
</syntaxhighlight> | |||
Then using it in-game: | |||
<sqf>player sideRadio "TAG_V01";</sqf> | |||
=== Editor === | |||
In markers and other [[:Category:Eden Editor|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. | |||
== 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 [[Multiplayer Scripting#Locality|global effect]] text commands (such as [[setMarkerText]]) would set the text in the server's language to everyone. | |||
// Server | Example of client-side translation of a server message: | ||
if ( | <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 | |||
}; | }; | ||
// | // Client-side executed function | ||
TAG_fnc_localHint = { | TAG_fnc_localHint = { | ||
if ( | if (hasInterface) then | ||
{ | |||
// hintSilent parseText (localize _this); // Arma 2 | |||
hintSilent parseText (_this call BIS_fnc_localize); // Arma 3 | |||
}; | }; | ||
}; | }; | ||
</ | </sqf> | ||
== Commands & Functions == | |||
See also [[:Category:Command Group: Localization|Command Group: Localization]]: | |||
== | * {{GVI|ofp|1.00|size= 0.75}} [[localize]] | ||
* {{GVI|arma3|0.50|size= 0.75}} [[isLocalized]] | |||
* {{GVI|arma3|1.00|size= 0.75}} [[BIS_fnc_localize]] | |||
* {{GVI|arma3|2.02|size= 0.75}} [[getTextRaw]] | |||
* {{GVI|arma3|2.04|size= 0.75}} [[diag_localized]] | |||
[[Category: | [[Category:BIS File Formats]] | ||
{{GameCategory|arma1|Editing}} | |||
{{GameCategory|arma2|Editing}} | |||
{{GameCategory|arma3|Editing}} |
Latest revision as of 10:41, 22 September 2023
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>sì</Italian>
<Polish>tak</Polish>
<Portuguese>sim</Portuguese>
<Russian>да</Russian>
<Spanish>sí</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 <t color='%1'>%2</t></Original>
</Key>
</Container>
</Package>
</Project>
Supported Languages
Arma 2 & Arma 2: Operation Arrowhead | Arma 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
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:
<t size='2'>Hello</t> there would then become <t size='2'>Hello</t> there.
Usage
Script
A translation can be retrieved and used in a script by using the localize command:
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";
overviewText = "$str_TAG_overviewText"; // invalid, will display "$str_TAG_overviewText" (with the $ sign)
onLoadMission = $STR_TAG_loadMissionText; // works without quotes but this is NOT recommended
The preprocessor will replace $STR entries with their corresponding Stringtable value.
Translated Sounds
The Stringtable can be used to use different voices depending on the user's language setting:
class CfgRadio
{
class TAG_V01
{
name = "$STR_TAG_V01_name";
sound[] = { "$STR_TAG_V01_path", 1, 1 };
title = "$STR_TAG_V01_subtitle";
};
};
the Stringtable's entries looking like this:
<Key ID="STR_V01_name">
<English>"Hello There" by OWK</English>
<French>"Salut à tous" par OWK</French>
</Key>
<Key ID="STR_V01_path">
<English>Sound\EN\v01.ogg</English>
<French>Sound\FR\v01.ogg</French>
</Key>
<Key ID="STR_V01_subtitle">
<English>Hello There!</English>
<French>Salut à tous !</French>
</Key>
Then using it in-game:
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.
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:
Commands & Functions
See also Command Group: Localization: