Stringtable.xml: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(Remove useless note, fix information presentation)
Line 1: Line 1:
==Stringtable.xml==
== Stringtable.xml ==
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's being read depending on the game settings.
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's being read depending on the game settings.


=====Example Format:=====
===== Example Format =====
<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<Project name="Any Name">
<Project name="Any Name">
Line 45: Line 45:
</syntaxhighlight>
</syntaxhighlight>


*Replace ''myTag'' in str_myTag_someKey with your OFPEC tag or other means of personal identification so other addon and mission string names won't collide, potentially breaking your mission - this is just good practice
'''Good practice:'''
*Package and container names appear to only be for organizational use; use them for your own sanity
* Replace ''myTag'' in str_myTag_someKey with your OFPEC tag or other means of personal identification so other addon and mission string names won't collide, potentially breaking your mission
{{Important|Stringtable.xml must be saved with UTF-8 Encoding for international characters to display and save correctly}}
* Package and container names appear to only be for organizational use; use them for your own sanity
{{Important|
Stringtable.xml must be saved with '''UTF-8 Encoding''' for international characters to display and save correctly!}}


=====Naming Key IDs=====
 
===== Naming Key IDs =====
If you are planning to use your <tt>stringtable.xml</tt> with scripts only, there are no rules in regards to naming format of Key IDs. [[localize]] and [[isLocalized]] will work with any name, as long as it matches Key ID name in <tt>stringtable.xml</tt>. For example:
If you are planning to use your <tt>stringtable.xml</tt> with scripts only, there are no rules in regards to naming format of Key IDs. [[localize]] and [[isLocalized]] will work with any name, as long as it matches Key ID name in <tt>stringtable.xml</tt>. For example:


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
// stringtable.xml
// stringtable.xml
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
Line 66: Line 69:
</syntaxhighlight>
</syntaxhighlight>


<code>// some script
<code>{{codecomment|// some script}}
[[hint]] [[str]] [[isLocalized]] "myCrazyNameTag"; // true;
[[hint]] [[str]] [[isLocalized]] "myCrazyNameTag"; {{codecomment|// true}}
[[hint]] [[str]] [[localize]] "myCrazyNameTag"; // "wuga wuga";</code>
[[hint]] [[str]] [[localize]] "myCrazyNameTag"; {{codecomment|// "wuga wuga"}}</code>


However, if you are also going to use <tt>stringtable.xml</tt> with configs, you '''must''' use special prefix <tt>$STR</tt> (dollar sign $ followed by uppercase STR) to reference Key ID in config. The Key IDs in <tt>stringtable.xml</tt> will have to start with "str" or "STR" accordingly, case doesn't matter here. For example:
However, if you are also going to use <tt>stringtable.xml</tt> with configs, you '''must''' use special prefix <tt>$STR</tt> (dollar sign $ followed by uppercase STR) to reference Key ID in config. The Key IDs in <tt>stringtable.xml</tt> will have to start with "str" or "STR" accordingly, case doesn't matter here.
{{Informative|By convention, an underscore <tt>_</tt> is added to the prefix <tt>STR_</tt> (<tt>$STR_</tt>). It provides clarity and makes <tt>stringtable.xml</tt> universally compatible with both scripts and configs.}}
For example:


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
// stringtable.xml
// stringtable.xml
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
Line 78: Line 83:
<Package name="Mission One">
<Package name="Mission One">
<Container name="Some Words">
<Container name="Some Words">
<Key ID="STRblahblah">
<Key ID="STR_myKey">
<Original>blah</Original>
<Original>Hey there</Original>
</Key>
</Key>
</Container>
</Container>
Line 86: Line 91:
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang=cpp>
<syntaxhighlight lang="cpp">
// some config
// config entry
class Test
class Test
{
{
word = $STRblahblah;
word = $STR_myKey;
};
};
</syntaxhighlight>
</syntaxhighlight>
<code>[[hint]] [[str]] [[getText]] ([[configFile]] >> "Test" >> "word"); // "blah"</code>
<code>[[hint]] [[str]] [[getText]] ([[configFile]] >> "Test" >> "word"); {{codecomment|// "Hey there"}}</code>
 
 
== Supported languages ==
 
=== {{arma3}} ===
* English
* Czech
* French
* Spanish
* Italian
* Polish
* Portuguese
* Russian
* German
* Korean (region exclusive)
* Japanese (region exclusive)
* Chinese 繁體中文 (Chinese Traditional)
* Chinesesimp 简体中文 (Chinese Simplified)
 
=== {{arma2oa}} ===
* English
* Czech
* French
* Spanish
* Italian
* Polish
* Russian
* German
 


By convention, an underscore <tt>_</tt> is added to the prefix <tt>STR_</tt> (<tt>$STR_</tt>). It provides clarity and makes <tt>stringtable.xml</tt> universally compatible with both scripts and configs.
== Usage ==


==Usage==
==== Scripts ====
====Scripts====
A string from [[Stringtable.xml]] can be retrieved and used in a script by using the [[localize]] command:
A string from stringtable.xml can be retrieved and used in a script by using the [[localize]] command:


<code>[[hint]] ( [[localize]] "str_myTag_Yes" );</code>
<code>[[hint]] [[localize]] "str_myTag_Yes";</code>


<code>"Marker1" [[setMarkerTextLocal]] [[localize]] "str_myTag_SiezeTheTown";</code>
<code>"Marker1" [[setMarkerTextLocal]] [[localize]] "str_myTag_SeizeTheTown";</code>


<code>[[hint]] [[format]] [ [[localize]] "str_myTag_formatted", "Dave" ]; // "Hello, Dave."
[[hint]] [[format]] [ [[localize]] "str_myTag_formatted", "Dave" ]; {{codecomment|// "Hello, Dave."}}
&nbsp;
{{codecomment|// str_myTag_formatted: <Original>Hello, %1.</Original>}}
// str_myTag_formatted: <Original>Hello, %1.</Original></code>




The stringtable can also hold [[Structured Text]] xml tags, if the tag characters < > are encoded as {{Inline_code| &amp;lt; < }} and {{Inline_code| &amp;gt; > }}  [http://www.w3schools.com/html/html_entities.asp see: HTML Entities]
The stringtable can also hold [[Structured Text]] xml tags, if the tag characters &lt; &gt; are encoded as {{Inline_code| &amp;lt; &lt; }} and {{Inline_code| &amp;gt; &gt; }}  [http://www.w3schools.com/html/html_entities.asp see: HTML Entities]


<code>[[hint]] [[parseText]] [[format]] [ [[localize]] "str_myTag_structured", "#FF0000", "with Color!" ]; //show 'with Color!' in Red
<code>[[hint]] [[parseText]] [[format]] [ [[localize]] "str_myTag_structured", "#FF0000", "with Color!" ]; //show 'with Color!' in Red
&nbsp;
&nbsp;
// str_myTag_structured: <English>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</English>
{{codecomment|// str_myTag_structured: <English>Some text &amp;lt;t color{{=}}'%1'&amp;gt;%2&amp;lt;/t&amp;gt;</English>}}
// after format & parseText: Some text <t color='#FF0000'>with Color!</t></code>
{{codecomment|// after format & parseText: Some text <t color{{=}}'#FF0000'>with Color!</t>}}</code>




====Description.ext====
==== Description.ext ====
Stringtable values can be used in the [[Description.ext]] config by typing the key as such, {{Inline_code| $STR_myTag_keyName }}, and without quotation marks; these will be replaced by the preprocessor:
Stringtable values can be used in the [[Description.ext]] config by typing the key as such, {{Inline_code| $STR_myTag_keyName }}, and without quotation marks; these will be replaced by the preprocessor:


Line 124: Line 156:
onLoadMission = $STR_myTag_loadMissionText;
onLoadMission = $STR_myTag_loadMissionText;
overviewText = $STR_myTag_overviewText;
overviewText = $STR_myTag_overviewText;
overviewPicture = $STR_myTag_overviewImage;
overviewPicture = $STR_myTag_overviewImage;</code>
</code>




====Dialogs====
==== Dialogs ====
As with Description.ext, the preprocessor will replace the values in configs as long as the key name is formatted correctly (see above) :
As with Description.ext, the preprocessor will replace the values in configs as long as the key name is formatted correctly (see above) :


<code>class RscText_1012: RscText
<code>class RscText_1012: RscText
{
{
idc = 1012;
idc = 1012;
text = $STR_myTag_someLabelText;
text = $STR_myTag_someLabelText;
tooltip = $STR_myTag_someTip;
tooltip = $STR_myTag_someTip;
...</code>
};</code>
 


====CfgRadio====
==== CfgRadio ====
Stringtables can also be used for sounds and radio sentences in [[Description.ext#cfgRadio|CfgRadio]], also residing in Description.ext:
Stringtable entries can also be used for sounds and radio sentences in [[Description.ext#cfgRadio|CfgRadio]], also residing in Description.ext:


<code>class CfgRadio
<code>class CfgRadio
Line 147: Line 180:
{
{
name = "";
name = "";
sound[] = {$STR_myTag_sound_RadioMsg1, db-100, 1.0};
sound[] = { $STR_myTag_sound_RadioMsg1, db-100, 1.0 };
title = $STR_myTag_RadioMsg1;
title = $STR_myTag_RadioMsg1;
};
};
};
};
// str_myTag_sound_RadioMsg1: <English>\sound\radiomsg1_en.ogg</English>
{{codecomment|// str_myTag_sound_RadioMsg1: <English>\sound\radiomsg1_en.ogg</English>
// <Czech>\sound\radiomsg1_cz.ogg</Czech>
// <Czech>\sound\radiomsg1_cz.ogg</Czech>
// str_myTag_RadioMsg1: <English>I am ready for your orders.</English>
// str_myTag_RadioMsg1: <English>I am ready for your orders.</English>}}</code>
</code>




====Multiplayer====
==== Multiplayer ====
{{Informative|'''Multiplayer Scripts''' should take care in considering implementation when clients and server are likely in varied localizations, and mindful of commands with global effects}}
{{Important|'''Multiplayer Scripts''' should consider their translation implementation when clients and server are likely in varied localizations, and mindful of commands with global effects (such as [[setMarkerText]] for example)}}


A string name could be passed to all clients for localized display:
A string name could be passed to all clients for localized display:
<code>str_myTag_teamKillers: <English>&amp;lt;t color='#dd1111'&amp;gt;Team Killing is NOT Tolerated&amp;lt;/t&amp;gt;&amp;lt;/ br&amp;gt; and will result in a Permanent Ban!</English>
<code>{{codecomment|// Server}}
 
[[if]] ([[isServer]]) [[then]] {
// Server
["str_myTag_myMessage","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
if ( [[isServer]] ) then {
};</code>
["str_myTag_teamKillers","TAG_fnc_localHint"] [[call]] [[BIS_fnc_MP]];
};
<code>{{codecomment|// Clients}}
 
// Clients
TAG_fnc_localHint = {
TAG_fnc_localHint = {
if ( ! [[isDedicated]] ) then {
[[if]] ([[not]] [[isDedicated]]) [[then]] {
[[hintSilent]] [[parseText]] ([[localize]] _this);
[[hintSilent]] [[parseText]] ([[localize]] [[_this]]);
};
};
};
};</code>
</code>
 
<!-- Do not include CSS styling in genuine example
Example 2:
<code style="white-space:pre-wrap;">{{Lorem|}}</code>
-->
 
{{Important|As far as editor tested, making task & task descrpition , dialog line(eg: blufor:incoming hostile! ) 'multi-languagued' is yet unavaliable.Only one languague can be used as <Original>****</Original> in this case.}}
 
==Languages==
;Arma 3
:English, Czech, French, Spanish, Italian, Polish, Portuguese, Russian, German, Korean**, Japanese**  ''(**region exclusive)'',繁體中文(Chinese Traditional),简体中文(Chinese Simplified)
;Arma 2 OA
:English, Czech, French, Spanish, Italian


==Comments==


[[Category:BIS_File_Formats]]
[[Category:BIS_File_Formats]]
[[Category:Arma 3: Editing]]
[[Category:Arma 3: Editing]]

Revision as of 02:52, 7 May 2018

Stringtable.xml

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's being read depending on the game settings.

Example Format
<?xml version="1.0" encoding="utf-8" ?>
<Project name="Any Name">
	<Package name="Mission One">
		<Container name="Some Words">
			<Key ID="str_myTag_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_myTag_No">
				<Original>no</Original>
			</Key>
		</Container>
		<Container name="Another Container">
			<Key ID="str_myTag_another_key">
				<Original></Original>
			</Key>
			<Key ID="str_myTag_formatted">
				<Original>Hello, %1.</Original>
			</Key>
			<Key ID="str_myTag_structured">
				<Original>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</Original>
			</Key>
		</Container>
	</Package>
</Project>

Good practice:

  • Replace myTag in str_myTag_someKey with your OFPEC tag or other means of personal identification so other addon and mission string names won't collide, potentially breaking your mission
  • Package and container names appear to only be for organizational use; use them for your own sanity
Stringtable.xml must be saved with UTF-8 Encoding for international characters to display and save correctly!


Naming Key IDs

If you are planning to use your stringtable.xml with scripts only, there are no rules in regards to naming format of Key IDs. localize and isLocalized will work with any name, as long as it matches Key ID name in stringtable.xml. For example:

// stringtable.xml
<?xml version="1.0" encoding="utf-8" ?>
<Project name="Any Name">
	<Package name="Mission One">
		<Container name="Some Words">
			<Key ID="myCrazyNameTag">
				<Original>wuga wuga</Original>
			</Key>
		</Container>
	</Package>
</Project>

// some script hint str isLocalized "myCrazyNameTag"; // true hint str localize "myCrazyNameTag"; // "wuga wuga"

However, if you are also going to use stringtable.xml with configs, you must use special prefix $STR (dollar sign $ followed by uppercase STR) to reference Key ID in config. The Key IDs in stringtable.xml will have to start with "str" or "STR" accordingly, case doesn't matter here.

By convention, an underscore _ is added to the prefix STR_ ($STR_). It provides clarity and makes stringtable.xml universally compatible with both scripts and configs.

For example:

// stringtable.xml
<?xml version="1.0" encoding="utf-8" ?>
<Project name="Any Name">
	<Package name="Mission One">
		<Container name="Some Words">
			<Key ID="STR_myKey">
				<Original>Hey there</Original>
			</Key>
		</Container>
	</Package>
</Project>
// config entry
class Test
{
	word = $STR_myKey;
};

hint str getText (configFile >> "Test" >> "word"); // "Hey there"


Supported languages

Arma 3

  • English
  • Czech
  • French
  • Spanish
  • Italian
  • Polish
  • Portuguese
  • Russian
  • German
  • Korean (region exclusive)
  • Japanese (region exclusive)
  • Chinese 繁體中文 (Chinese Traditional)
  • Chinesesimp 简体中文 (Chinese Simplified)

Arma 2: Operation Arrowhead

  • English
  • Czech
  • French
  • Spanish
  • Italian
  • Polish
  • Russian
  • German


Usage

Scripts

A string from Stringtable.xml can be retrieved and used in a script by using the localize command:

hint localize "str_myTag_Yes";

"Marker1" setMarkerTextLocal localize "str_myTag_SeizeTheTown";

hint format [ localize "str_myTag_formatted", "Dave" ]; // "Hello, Dave."
// str_myTag_formatted:		<Original>Hello, %1.</Original>


The stringtable can also hold Structured Text xml tags, if the tag characters < > are encoded as &lt; < and &gt; > see: HTML Entities

hint parseText format [ localize "str_myTag_structured", "#FF0000", "with Color!" ]; //show 'with Color!' in Red   // str_myTag_structured: <English>Some text &lt;t color='%1'&gt;%2&lt;/t&gt;</English> // after format & parseText: Some text <t color='#FF0000'>with Color!</t>


Description.ext

Stringtable values can be used in the Description.ext config by typing the key as such, $STR_myTag_keyName , and without quotation marks; these will be replaced by the preprocessor:

onLoadName = $STR_myTag_missionName; onLoadMission = $STR_myTag_loadMissionText; overviewText = $STR_myTag_overviewText; overviewPicture = $STR_myTag_overviewImage;


Dialogs

As with Description.ext, the preprocessor will replace the values in configs as long as the key name is formatted correctly (see above) :

class RscText_1012: RscText { idc = 1012; text = $STR_myTag_someLabelText; tooltip = $STR_myTag_someTip; … };


CfgRadio

Stringtable entries can also be used for sounds and radio sentences in CfgRadio, also residing in Description.ext:

class CfgRadio { sounds[] = {}; class RadioMsg1 { name = ""; sound[] = { $STR_myTag_sound_RadioMsg1, db-100, 1.0 }; title = $STR_myTag_RadioMsg1; }; }; // str_myTag_sound_RadioMsg1: <English>\sound\radiomsg1_en.ogg</English> // <Czech>\sound\radiomsg1_cz.ogg</Czech> // str_myTag_RadioMsg1: <English>I am ready for your orders.</English>


Multiplayer

Multiplayer Scripts should consider their translation implementation when clients and server are likely in varied localizations, and mindful of commands with global effects (such as setMarkerText for example)

A string name could be passed to all clients for localized display: // Server if (isServer) then { ["str_myTag_myMessage","TAG_fnc_localHint"] call BIS_fnc_MP; };

// Clients TAG_fnc_localHint = { if (not isDedicated) then { hintSilent parseText (localize _this); }; };