Difference between revisions of "Stringtable.xml"
Lou Montana (talk | contribs)
m (Some wiki formatting)
(→Supported languages: rpt message unsupported language english)
|Line 204:||Line 204:|
== Key naming convention ==
== Key naming convention ==
Revision as of 00:46, 19 June 2022
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.
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.
<?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>
|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).
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 < and >.
<t size='2'>Hello</t> there would then become <t size='2'>Hello</t> there.
A translation can be retrieved and used in a script by using the localize command:
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.
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 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: