Stringtable.csv: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - " (={2,})([^ = ])(.*)([^ = ])(={2,}) * " to " $1 $2$3$4 $5 ") |
Lou Montana (talk | contribs) m (Text replacement - "\{\{( *)Important( *)\|" to "{{$1Feature$2|$2important$2|") |
||
Line 113: | Line 113: | ||
Markers, texting effects, mission name, ...: | Markers, texting effects, mission name, ...: | ||
{{ | {{Feature|important|Note: If adding string table entry through the mission editor, the proper syntax is automatically added to the mission.sqm, if you are converting a mission from OFP to ArmA, you may need re-add the string table to avoid the "scalar bool array string 0xe0ffffef" error}} | ||
:* OFP | :* OFP |
Revision as of 02:08, 7 February 2021
Purpose
Stringtables are used to make internationalization easier for the game. They are used in addons, missions, and scripts.
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 message strings directly in the code you are using a variable. This variable will then contain the actual string, read from stringtable.csv, with the language that's being read depending on the game settings.
CSV (Comma Separated Values) Format
The file stringtable.csv is an ASCII text file, and can be edited with any text editor. One could theoretically use a spreadsheet program (like Excel) to edit the file, but that would be serious overkill. 'DO NOT use a word processor (like MS-Word, or Write) to edit this file though, as it will corrupt it, unless you are very knowledgeable and careful.
- Operation Flashpoint uses ANSI encoding, the codepage is defined by the font used.
- Operation Flashpoint cannot accept UTF encoding. You need to convert back to ANSI (e.g remove the 3 byte UTF "BOM" (byte order mark) tag at beginning of file when converting back the the real game).
- Armed Assault accepts ANSI, Unicode and UTF-8 encoding (Unicode will be converted to UTF-8 on load)
- Arma 2 and Arma 3 both accept CSV but use Stringtable.xml in preference. For whatever reason, Bohemia Interactive have destroyed the default language. It is no longer possible to simply state
STR_ANYTHING,Some Name
and have all languages accept it. You will get a 'blank' if a specific language (e.g 'german') is not endlessly repeated as well.
Function
CSV files are used in Operation Flashpoint exclusively as a string lookup tables.
Although the engine uses other files with the extension CSV, the file for missions, addons, and campaigns is 'stringtable.csv' and must be located in the primary folder of the mission, the addon, or, the campaign.
In point of fact, the naming convention inside a csv is such that the first three letters of any variable (more later) must begin with STR, and referenced in mission.sqm, description,ext or anywhere else as $STRsomething.
The characters STR tell the engine to look in 'stringtable.csv' as opposed to somewhere else.
Format
Language Columns
The basic idea is that every language is assigned one column. (e.g. English has one column, French has another.) The order of the columns doesn't matter. (i.e. whether English comes first, or French, or Czech, is irrelevant). However, when game language doesn't match any of the languages listed in stringtable, the first column is selected by default. Therefore it is recommended to use English there.
The very first line of any csv must contain a statement like this:
LANGUAGE, Polish, Hungarian, Turkish
With this line you define the order in which the language columns are arranged. You can have as many or as few as you like.
Below this line the CSV file contains one line for each string definition; starting with the string name, and followed by the translations for the different languages:
Language, English,Turkish,French STR_BROKEN,Broken, Bozuk, Merde STR_GOOD, Good, İyi, STR_BAD, Bad, Kotu, Merde, Encore STR_FIXED, Fixed, Sabit, "Merde, Encore" STR_ONE, One, , Une
Blank Strings
Note some interesting and highly flexible aspects of the above syntax.
There is no French equivalent for STR_GOOD. Nor is there a Turkish equivalent for ONE. The engine will default to the 2nd column. It happens to be 'English', but need not be.
ArmA: In ArmA this is different. If your country column exists, it will use that string, even if it is blank and not default to the 2nd column. So do not include languages in the LANGUAGE row, which you are not utilising yet.
Default Language Column
The second column (the first 'string') is the default. Because of that, it is important that all of the 2nd columns are filled.
The second column doesn't have to be English - it can be any language the author is most comfortable with, and for which he will be able to supply all the required definitions. In that case though, he will have to adjust the "LANGUAGE, ..." column definition at the top of the file.
ArmA: In ArmA, if your language column is missing, then it will default to the game distributor language column, if it exists. So if you own the German version of the game and a German column exists in any column and your chosen language is not in any column, then German will be used, even if German is not in the 2nd column.
Commas and Quotes
To separate strings from one another, commas are used. String do not have to be enclosed with quotation marks. In the case that commas are needed in the string definition itself, then that string would have to be enclosed by quotes (e.g. "Merde, Encore" you would need quotes.)
Leading/Trailing Spaces
When defining a string, the text used by the engine is from the first non space character after a comma, until the last non space character before the next comma (or end of line). This would be familiar to many programmers as the Trim() function.
Thus
,this is a text, , this is a text ,
would both return "this is a text".
This feature is helpful if you want to keep columns aligned (tabbed), to keep better track of the columns.
Usage
Definition in stringtable.csv:
LANGUAGE, English, German STR_MOVETO, Move to the, Gehen sie zum STR_STATION, railroad station, Bahnhof STR_AIRPORT, airport, Flughafen
Scripts
Activations and conditions too.
- ArmA
_text = (localize "STR_MOVETO") + " " + (localize "STR_AIRPORT");
- OFP
_text = $STR_MOVETO + " " + $STR_AIRPORT
description.ext
$STR_AIRPORT
mission.sqm
Markers, texting effects, mission name, ...:
- OFP
@STR_AIRPORT
- ArmA
"@STR_AIRPORT"
Comments
- Arma: Arma doesn't appear to accept any (type of) comment string. Every line appears to be a string entry to Arma, with obvious consequences when converting from a properly documented (commented) Operation Flashpoint csv
Any syntax the engine cannot understand is interpreted as a comment.
By convention the double-forward slash (//) at the beginning of the line is used:
LANGUAGE, English, German // actions STR_MOVETO, Move to the, Gehen sie zum STR_DESTROY, Destroy the, Zerstören sie den // locations STR_STATION, railroad station, Bahnhof STR_AIRPORT, airport, Flughafen
However, in practice anything that doesn't start with STR can only be a comment.
- Arma 2: To insert a string refering to a stringtable.csv or stringtable.xml, don't use the "" in the editor.
For example: you have the STR_myString. To add it in the description field of the selected unit, just add it like @STR_myString, the "" will be added, self-acting by the editor, in the mission.sqm.
The selected language
flashpoint.cfg in the root directory of your operation flashpoint folder defines the language to be used for your installation:
Language="English";
This can be changed to any language that has valid entries in the stringtable.csv's. For more information on this subject read Language Selection.
Replacing original game texts
It is possible to replace every message of the original game by editing the global stringtable.csv file (in \res\bin\stringtable.csv). (Some messages, like addon names some GUI texts, briefing chapters (Plan, Notes, Gear, Group), etc. cannot be changed via the stringtable.csv though).
For example, you can create custom radio names for your squads.
Create your group and give them a normal radio name with the following command in the init line of the commander.
this setGroupId ["Alpha", "GroupColor0"]
Now, add in your Stringtable.csv:
STR_CFG_GRPNAMES_ALPHA, "Your group name", STR_CFG_GRPCOL_BLACK, "Your color name",
Where Your group name is the custom name you'd like your squad radio messages to have, Your color name is color of the squad (GroupColor0 is Black, for more details see setGroupId).
Different sounds under different languages
You can use stringtable.csv not only for texts but sounds and other Description.ext classes. See example:
stringtable.csv
LANGUAGE,"English","Polish" STR_R1,"ENGLISH","POLSKI" STR_R2,"US AND A SOLDIER HERE.","TUTAJ POLSKI ŻOŁNIERZ." STR_RadioMsg1,"ENG\R1.WAV","POL\R1.WAV" STR_RadioMsg2,"ENG\R2.WAV","POL\R2.WAV"
Of course all sounds we have in Sound directory. Moreover they are in two different folders: POL and ENG. It makes Sound more clean. You can use prefixes like: eng_ or pol_ insted.
Description.ext (CfgRadio class only)
class CfgRadio
{
sounds[] = { };
class R1
{
name = "Radio #01";
sound[] = {$STR_RadioMsg1, db+10, 1.0};
title = $STR_R1;
};
class R2
{
name = "Radio #02";
sound[] = {$STR_RadioMsg2, db+10, 1.0};
title = $STR_R2;
};
};
How it works? During loading, Description.ext exactly, all string values preceded with $ (dollar) are changed on right entires from stringtable.csv. So when a player run game under English language, he (or she) will have English texts and sounds. The same think with Polish and other specified languages.
This solution you can use for CfgIdentities class to create personages with translated names or even native faces.
Notes:
- There are instances where the radio name will revert to the default after a reload of the mission.
class CfgSounds
{
sounds[]={ ListOfClassNames... };
class 07av1
{
name = "";
sound[] = {"07av01.ogg", db, 1.0};
titles[] =
{
0, $STRCAMP_07av01
};
};
(...)
class AnotherClassName
{
name = "";
sound[] = {"Another.ogg", db, 1.0};
titles[] =
{
{0, $STR_SomeCsvString}, // one piece of voice text
{{6,0.5}, $STR_AnotherCsvString} // then another
};
};
};