Strangepete/Sandbox – User
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
==Stringtable.xml== | ==Stringtable.xml== | ||
{{note|Work-in-Progress : input on relevance/implementation in arma 2 requested, im looking...}} | |||
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===== | |||
<code><?xml version="1.0" encoding="utf-8" ?> | <code><?xml version="1.0" encoding="utf-8" ?> | ||
<Project name="Any Name"> | <Project name="Any Name"> | ||
Line 42: | Line 42: | ||
</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 | ||
{{Important|Stringtable.xml must be saved with UTF-8 Encoding for international characters to display 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}} | |||
==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>[[hint]] ( [[localize]] "str_myTag_Yes" );</code> | ||
_twoStrings = (localize "str_myTag_String1") + (localize "str_tag_String2"); | <code>_twoStrings = ( [[localize]] "str_myTag_String1" ) + ( [[localize]] "str_tag_String2" );</code> | ||
<code>[[hint]] [[format]] [ [[localize]] "str_myTag_formatted", "Dave" ]; // "Hello, Dave." | |||
| | ||
// stringtable: <Original>Hello, %1.</Original></code> | // stringtable: <Original>Hello, %1.</Original></code> | ||
The stringtable can also hold [[Structured Text]] xml tags, if the tag characters < > are encoded as [http://www.w3schools.com/html/html_entities.asp HTML Entities] | The stringtable can also hold [[Structured Text]] xml tags, if the tag characters < > are encoded as {{Inline_code| &lt; < }} and {{Inline_code| &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 | |||
| | ||
// stringtable: <English>Some text &lt;t color='%1'&gt;%2&lt;/t&gt;</English> | // stringtable: <English>Some text &lt;t color='%1'&gt;%2&lt;/t&gt;</English> | ||
Line 67: | Line 67: | ||
====Description.ext==== | ====Description.ext==== | ||
Stringtable values can be used in the [[Description.ext]] config by typing the key as such, | 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: | ||
<code>onLoadName=$STR_myTag_missionName; | <code>onLoadName = $STR_myTag_missionName; | ||
onLoadMission = $STR_myTag_loadMissionText; | onLoadMission = $STR_myTag_loadMissionText; | ||
overviewText = $STR_myTag_overviewText; | overviewText = $STR_myTag_overviewText; | ||
overviewPicture = "intro.paa"; | overviewPicture = "intro.paa"; | ||
loadScreen = "intro.paa"; | |||
author="me";</code> | author="me";</code> | ||
====Dialogs==== | ====Dialogs & Configs==== | ||
As with Description.ext, the preprocessor will replace the values 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> | <code>class RscText_1012: RscText | ||
class RscText_1012: RscText | |||
{ | { | ||
idc = 1012; | idc = 1012; | ||
Line 100: | Line 99: | ||
;Arma 2 | ;Arma 2 | ||
:...? | :...? | ||
==Comments== | ==Comments== | ||
[[Category:BIS_File_Formats]] | |||
[[Category:Arma 3: Editing]] |
Revision as of 14:44, 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 <t color='%1'>%2</t></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
- Package and container names appear to only be for organizational use; use them for your own sanity
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."
// stringtable: <Original>Hello, %1.</Original>
The stringtable can also hold Structured Text xml tags, if the tag characters < > are encoded as < <
and > >
see: HTML Entities
hint parseText format [ localize "str_myTag_structured", "#FF0000", "with Color!" ]; //show 'with Color!' in Red
// stringtable: <English>Some text <t color='%1'>%2</t></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 & Configs
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;
...
Languages
- Arma 3
- Czech
- English
- French
- German
- Italian
- Polish
- Portuguese
- Russian
- Spanish
- Arma 2
- ...?