CSV File Format - Stringtables

From Bohemia Interactive Community
Revision as of 03:56, 21 July 2006 by Mikero (talk | contribs) (released for public ridicule)
Jump to navigation Jump to search

work in progress

CSV (comma separated values)

Because of the unfortunate, but perfectly reasonable, filename extension, people associate this file as something to do with Micro$oft Excell and spreadsheets.

In a very limited way, this file is spreadsheet data, but, to use a spreadsheet tool for it is a) erroneous, b) ridiculous.

Use your notepad editor for these file types.

Purpose

csv files are used in Operation Flashpoint exclusively as a language translator.

Although the engine uses differently named csv's, the csv for missions, addons, and campaigns is hardwired to '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.

Why Bother?

Well if you can't be bothered, stop reading, but, there are two abundantly clear reasons for anyone serious about the missions (or addons) they make. Without a stringtable.csv, you're not 'proud' about your creation:

  1. Save yourself the agony of hunting through your scripts and missions and blah looking for that 'thing' you wrote but umm err, well hell, where did i put it.
  1. If you want to internationalise your mission, making it more appealable, more playable by everyone, use stringtables.

Layout

Intent

The basic idea is that any language is in columns. English in one column, French in another. The order (whether French or English) comes first is immaterial. It is the column that is all-important

Basics

The very first line of any csv must contain the statement

LANGUAGE,  Polish, Hungarian, Turkish,,,,,.

It should not take rocket science for you to substitute the above 'languages' with something more pertinent. The point being illustrated is that you can add any language!!!! That's right. ANY language.

From then on, the csv file contains lines of substitute text. Substitute means, it will replace in the game, a piece of text, from a given column. An example

Language,  English,Turkish,French,Comment
STR_BROKEN,Broken, Bozuk,  Merde, dunno
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.

You can be guaranteed that the 2nd column is fully filled for all string tokens. It is, after all, the beginning piece for the author for any language he cares to write in. Thus, for a Polish author making a Polish mission, you can be certain, the 2nd column is declared as Polish and all strings defined. (and this becomes the default language for the engine when playing the 'mission')

Secondly, the only criteria is the comma. "Merde Encore" does not require quotes.

The only use of quotes in a csv file are to pervert commas. 

Thus for the phrase "Merde, Encore" you would need quotes.

3rd, the language 'Comment' is just as valid as any other, the engine can handle the 'Comment' language, anything placed there would be shown (which would be, let's say, a little odd). Whether you choose to add a comment column is up to you and mostly unnecessary.

You can choose to have as many or as little languages as you like. The only criteria is you must have one language minimum. The default one in the second column when nothing else exists.

Finally, when forming phrases, 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       ,

are both clipped to the first form.

This is very helpful to you if you want to keep columns aligned (tabbed).

Usage

One example should suffice

in mission.sqm (eg)

text = "Alexi's sister\nAlexi's mother\nMy brother";
text = $STR_FAMILY;

in stringtable.csv

STR_FAMILY,   Alexi's sister\nAlexi's mother\nMy brother, blib\n\blab\blob, more more more

Note the requirement for $STRxyz and STRxyz and that should be it for anything you care to place in a stringtable.

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

flahspoint.cfg in the root directory of your operation flashpoint folder contains THE language you prefer to use. The statement

Language="English";

could not be more simple, or more obvious on what to change (if you want to) You can, if it suits you write

Language = "Pongolian"

and create stringtable.csv's specifically written in Pongolian. For more information on this subject read Language Selection.