Stringtable.xml: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fix config STR)
m (Fix the fix)
Line 215: Line 215:
== Key naming convention ==
== Key naming convention ==


* If the key is to be used in a [[Config|config]], it '''must''' start with <tt>STR</tt> '''and''' respect casing (e.g <tt>STR_camelCase</tt> and not <tt>str_Camelcase</tt>).
* If the key is to be used in a [[Config|config]], it '''must''' start with '''uppercase''' <tt>STR</tt>.
* Same as [[Identifier#Recommendations|global variables]], it is recommended to use a '''{{Color|purple|TAG}}''' to prevent translation collision with mods (e.g <tt>STR_{{Color|purple|TAG}}_helloThere</tt>).
* Same as [[Identifier#Recommendations|global variables]], it is recommended to use a '''{{Color|purple|TAG}}''' to prevent translation collision with mods (e.g <tt>STR_{{Color|purple|TAG}}_helloThere</tt>).


Line 241: Line 241:
=== Config ===
=== Config ===


Whether it is in [[Description.ext]], [[Campaign Description.ext]], Dialogs etc., a translated [[Config]] entry '''must''' use the <tt>$</tt> prefix and respect casing as well  (e.g <tt>$STR_camelCase</tt> and not <tt>$str_Camelcase</tt>) for the engine to look the translation key up:
Whether it is in [[Description.ext]], [[Campaign Description.ext]], Dialogs etc., a translated [[Config]] entry '''must''' use the <tt>$</tt> prefix (to an '''uppercase''' <tt>STR</tt>) for the engine to look the translation key up:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">

Revision as of 05:24, 20 December 2020

Template:SideTOC

Stringtable.xml was introduced with Arma. 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 한국어 Region exclusive (TBC)
Japanese 日本語 Region exclusive (TBC)
Chinese 繁體中文 Chinese Traditional
Chinesesimp 简体中文 Chinese Simplified
Turkish Türkçe
Swedish N/A Not available in-game
Slovak N/A Not available in-game
SerboCroatian N/A Not available in-game
Norwegian N/A Not available in-game
Icelandic N/A Not available in-game
Hungarian Magyar Not available in-game
Greek N/A Not available in-game
Finnish N/A Not available in-game
Dutch N/A Not available in-game

Key naming convention

  • If the key is to be used in a config, it must start with uppercase STR.
  • Same as global variables, it is recommended to use a TAG to prevent translation collision with 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";

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;
overviewText = $STR_TAG_overviewText;
overviewPicture = $STR_TAG_overviewImage;

The preprocessor will replace $STR entries with the Stringtable values.

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.


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