Stringtable.csv: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - "y[ _]*\|[ _]*ofp[ _]*\|[ _]+" to "y|ofp|") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
== CSV | == CSV Format == | ||
The | The '''Stringtable.csv''' file 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. | |||
* [[:Category:Operation Flashpoint|{{ofp}}]] uses {{ | {{Feature|informative|CSV stands for Comma-Separated Values. Using e.g Microsoft Excel to edit this file ''may'' corrupt the file, as some language settings will use a semicolon {{hl|;}} instead of a comma {{hl|,}}.}} | ||
* [[:Category:Operation Flashpoint|{{ofp}}]] uses {{Link|https://en.wikipedia.org/wiki/ANSI}} encoding, the codepage is defined by the font used. | |||
** [[:Category:Operation Flashpoint|{{ofp}}]] 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). | ** [[:Category:Operation Flashpoint|{{ofp}}]] 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, {{ | * [[:Category:ArmA: Armed Assault|{{arma1}}]] accepts ANSI, {{Link|https://en.wikipedia.org/wiki/Unicode}} and {{Link|https://en.wikipedia.org/wiki/UTF-8}} encoding (Unicode will be converted to UTF-8 on load) | ||
* {{arma2}} and {{arma3}} 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 | * {{arma2}} and {{arma3}} 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 | STR_ANYTHING,Some Name | ||
Line 23: | Line 27: | ||
== Function == | == Function == | ||
CSV files are used | CSV files are used as 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 | 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/addon/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 | 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 {{hl|STR}}, and referenced in mission.sqm, description.ext or anywhere else as {{hl|$STRsomething}}. | ||
The characters STR tell the engine to look in 'stringtable.csv' as opposed to | The characters {{hl|STR}} tell the engine to look in 'stringtable.csv' as opposed to use the literal string value. | ||
Line 57: | Line 61: | ||
Note some interesting and highly flexible aspects of the above syntax. | Note some interesting and highly flexible aspects of the above syntax. | ||
There is '''no''' French equivalent for STR_GOOD | There is '''no''' French equivalent for {{hl|STR_GOOD}}, nor is there a Turkish equivalent for {{hl|STR_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 | '''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 === | === Default Language Column === | ||
Line 65: | Line 69: | ||
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 (the first 'string') is the default. Because of that, it is important that ''all'' of the 2nd columns are filled. | ||
The second column | The second column does not ''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. | '''ArmA:''' In ArmA, if your language column is missing, then it will default to the game distributor's 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. | 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 === | === 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. | 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 === | === 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. | 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 | Thus | ||
Line 99: | Line 106: | ||
Activations and conditions too. | Activations and conditions too. | ||
{{arma}} | |||
<sqf>_text = localize "STR_MOVETO" + " " + localize "STR_AIRPORT";</sqf> | |||
{{ofp}} | |||
_text = $STR_MOVETO + " " + $STR_AIRPORT | _text = $STR_MOVETO + " " + $STR_AIRPORT | ||
<!-- can't <sqf> this one --> | |||
=== [[Description.ext|description.ext]] === | === [[Description.ext|description.ext]] === | ||
$STR_AIRPORT | <syntaxhighlight lang="cpp"> | ||
"$STR_AIRPORT" | |||
</syntaxhighlight> | |||
=== mission.sqm === | === mission.sqm === | ||
Markers, texting effects, mission name, | Markers, texting effects, mission name, etc: | ||
{{Feature|important| | {{Feature|important| | ||
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 {{hl|"scalar bool array string 0xe0ffffef"}} error. | |||
}} | |||
{{ofp}} | |||
@STR_AIRPORT | @STR_AIRPORT | ||
{{arma}} | |||
"@STR_AIRPORT" | "@STR_AIRPORT" | ||
Line 141: | Line 154: | ||
{{arma2}}: To insert a string refering to a stringtable.csv or stringtable.xml, don't use the "" in the editor. | |||
For example: you have | For example: you have {{hl|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 | To add it in the description field of the selected unit, just add it like {{hl|@STR_myString}}, the "" will be added, self-acting by the editor, in mission.sqm. | ||
== The selected language == | == The selected language == | ||
flashpoint.cfg in the root directory of your operation flashpoint folder defines the language to be used for your installation: | {{hl|flashpoint.cfg}} in the root directory of your operation flashpoint folder defines the language to be used for your installation: | ||
<syntaxhighlight lang="cpp"> | |||
Language="English"; | |||
</syntaxhighlight> | |||
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]]. | 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]]. | ||
Line 156: | Line 171: | ||
== Replacing original game texts == | == 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). | 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. | For example, you can create custom radio names for your squads. | ||
Line 162: | Line 178: | ||
Create your group and give them a normal radio name with the following command in the init line of the commander. | Create your group and give them a normal radio name with the following command in the init line of the commander. | ||
<sqf>this setGroupId ["Alpha", "GroupColor0"];</sqf> | |||
Now, add in your [[Stringtable.csv]]: | Now, add in your [[Stringtable.csv]]: | ||
Line 191: | Line 207: | ||
class CfgRadio | class CfgRadio | ||
{ | { | ||
sounds[] = { }; | sounds[] = {}; | ||
class R1 | class R1 | ||
{ | { | ||
name = "Radio #01"; | name = "Radio #01"; | ||
sound[] = {$STR_RadioMsg1, db+10, 1.0}; | sound[] = { "$STR_RadioMsg1", db + 10, 1.0 }; | ||
title = $STR_R1; | title = "$STR_R1"; | ||
}; | }; | ||
class R2 | class R2 | ||
{ | { | ||
name = "Radio #02"; | name = "Radio #02"; | ||
sound[] = {$STR_RadioMsg2, db+10, 1.0}; | sound[] = { "$STR_RadioMsg2", db + 10, 1.0 }; | ||
title = $STR_R2; | title = "$STR_R2"; | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
How it | How does it work? 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, they will have English texts and sounds. The same think with Polish and other specified languages. | |||
This solution you can use for [[Description.ext#Identities|CfgIdentities]] class to create personages with translated names or even native faces. | This solution you can use for [[Description.ext#Identities|CfgIdentities]] class to create personages with translated names or even native faces. | ||
'''Notes:''' | '''Notes:'''<br> | ||
There are instances where the radio name will revert to the default after a reload of the mission. | |||
<syntaxhighlight lang="cpp"> | <syntaxhighlight lang="cpp"> | ||
class CfgSounds | class CfgSounds | ||
{ | { | ||
sounds[]={ | sounds[] = { 07av1 /* etc */ }; | ||
class 07av1 | class 07av1 | ||
{ | { | ||
name = ""; | name = ""; | ||
sound[] = {"07av01.ogg", db, 1.0}; | sound[] = {"07av01.ogg", db, 1.0}; | ||
titles[] = | titles[] = { 0, "$STRCAMP_07av01" }; | ||
}; | }; | ||
(...) | // (...) | ||
class AnotherClassName | class AnotherClassName | ||
{ | { | ||
name = ""; | name = ""; | ||
sound[] = {"Another.ogg", db, 1.0}; | sound[] = { "Another.ogg", db, 1.0 }; | ||
titles[] = | titles[] = | ||
{ | { | ||
{0, $STR_SomeCsvString}, | { 0, "$STR_SomeCsvString" }, // one piece of voice text | ||
{ 6, "$STR_AnotherCsvString" } // then another | |||
}; | }; | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{GameCategory|ofp|Editing}} | {{GameCategory|ofp|Editing}} |
Latest revision as of 20:24, 22 April 2024
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 Format
The Stringtable.csv file 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 as 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/addon/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 use the literal string value.
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 STR_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 does not 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's 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
Operation Flashpoint
_text = $STR_MOVETO + " " + $STR_AIRPORT
description.ext
"$STR_AIRPORT"
mission.sqm
Markers, texting effects, mission name, etc:
Operation Flashpoint
@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 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 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.
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 does it work? 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, they 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[] = { 07av1 /* etc */ };
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, "$STR_AnotherCsvString" } // then another
};
};
};