CSV File Format - Stringtables: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
Line 2: Line 2:
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.
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]] and [[VBS1]] use ANSI encoding, codepage is defined by the font used. [[Armed Assault]] and [[VBS2]] use [http://en.wikipedia.org/wiki/UTF-8 UTF-8] encoding, or you can provide the file in [http://en.wikipedia.org/wiki/Unicode Unicode] as well, in which case it will be converted to UTF-8 when loading.


==Purpose==
==Purpose==

Revision as of 14:53, 9 January 2007

CSV (comma separated values)

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 and VBS1 use ANSI encoding, codepage is defined by the font used. Armed Assault and VBS2 use UTF-8 encoding, or you can provide the file in Unicode as well, in which case it will be converted to UTF-8 when loading.

Purpose

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

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.)

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,   Guzel,
STR_BAD,   Bad,    Hayar, Merde Encore
STR_ONE,   One,         , Une

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!

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.

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.)

Finally, 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

usage in mission.sqm and scripts: (ArmA)

_text = localize STR_MOVETO + localize STR_AIRPORT; (would result in "Move to the airport" for an 

(OFP)

_text = $STR_MOVETO + $STR_AIRPORT

usage in markers:

@STR_AIRPORT

Comments

//Essentially, any syntax the engine cannot understand, becomes a comment, a non event, a non-part, of the columns. By // convention the // as illustrated here is used. However, in practice

Anything that doesn't start with STR can only be a comment!


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, in your stringtable.cvs add;

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).


Notes:

  • There are instances where the radio name will revert to the default after a reload of the mission.