Strangepete/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
(request for contributions - will eventually be page 'Stringtable.xml')
Line 1: Line 1:
==Stringtable.xml==
==Stringtable.xml==
{{note|Work-in-Progress : input on relevance/implementation in arma 2 requested, im looking...}}
{{note|Work-in-Progress : please contribute here if you see anything or want to add anything...
*input on implementation in arma 2 requested: eg, languages, compatibility with arma3 xml? etc.
*use of @STR_ in mission.sqm and via Mission Editor - still valid? working example?
*proof read}}
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 42: Line 45:
</code>
</code>


*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
*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
*Package and container names appear to only be for organizational use; use them for your own sanity
*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}}
{{Important|Stringtable.xml must be saved with UTF-8 Encoding for international characters to display and save correctly}}
Line 56: Line 59:
<code>[[hint]] [[format]] [ [[localize]] "str_myTag_formatted", "Dave" ]; // "Hello, Dave."
<code>[[hint]] [[format]] [ [[localize]] "str_myTag_formatted", "Dave" ]; // "Hello, Dave."
&nbsp;
&nbsp;
// stringtable: <Original>Hello, %1.</Original></code>
// str_myTag_formatted: <Original>Hello, %1.</Original></code>




Line 63: Line 66:
<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;
// stringtable: <English>Some text &amp;lt;t color='%1'&amp;gt;%2&amp;lt;/t&amp;gt;</English>
// 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>
// after format & parseText: Some text <t color='#FF0000'>with Color!</t></code>


====Description.ext====
====Description.ext====
Line 76: Line 80:
author="me";</code>
author="me";</code>


====Dialogs & Configs====
 
====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) :


Line 85: Line 90:
tooltip = $STR_myTag_someTip;
tooltip = $STR_myTag_someTip;
...</code>
...</code>
====CfgRadio====
Stringtables can also be used for sounds and radio sentences in [[Description.ext#cfgRadio|CfgRadio]], also residing in Description.ext:
<code>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>
</code>


==Languages==
==Languages==

Revision as of 23:46, 2 April 2014

Stringtable.xml

Template:note 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>sì</Italian> <Polish>tak</Polish> <Portuguese>sim</Portuguese> <Russian>да</Russian> <Spanish>sí</Spanish> </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 &lt;t color='%1'&gt;%2&lt;/t&gt;</Original> </Key> </Container> </Package> </Project>

  • 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
  • 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

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" );

_twoStrings = ( localize "str_myTag_String1" ) + ( localize "str_tag_String2" );

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 = "intro.paa"; loadScreen = "intro.paa"; author="me";


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

Stringtables 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>

Languages

Arma 3
Czech
English
French
German
Italian
Polish
Portuguese
Russian
Spanish
Arma 2
...?

Comments