Documentation for localisation and localisation scripting.
Very much work in progress right now and subject to changes at any moment.
Resources:
-
As a translator you will need to know very few things about C language. Copy, paste and modify from other languages examples should be enough to have your translation running in most cases.
But if you want go a step further and learn how to code complex auxiliary functions, or you have any coding related doubt, you can find lots of information and tutorials about C language online:
Learn C Programming -
We recommend using notepad++ a light but powerful open source tool to edit language definitions, loc files and scripts. Of course it’s also free:
https://notepad-plus-plus.org/
Glossary:
-
sOut
sOut is the output string in every localisation script.
You don’t need to create or define sOut, we create it for you as an empty string L"".
After the script execution we read sOut and use its content as the final translation text.
Types of variables and Notation:
To easily recognise the type of information contained in the variables we use a single character lower case prefix in variables names. This is important because in C operations, assignments or comparisons can only be performed between the same types of variables.
Variables are declared and initialised this way:
variableType variableName = VariableValue;
- A char is a single character.
Character are defined with ’ like in:
char h = L'h';
- A wchar_t is a string which is actually an array of characters.
Strings variable names have a low case s prefix: sString, sName, sVerb, etc…
Strings are defined with " like in:
wchar_t sHouse = L"house";
- A integer is a numeric value with no decimals.
Integer number variable names have a low case n prefix: nNumber, nNumber, nQuantity, etc…
int nYear = -10000;
- A float is a numeric value with decimals.
Float number variable names have a low case n prefix: nNumber, nPrize, etc…
and the value itself need a f suffix.
float nPi = 3.1416f;
- An array -or vector- is a collection of values of the same type
Arrays variable names have a low case v prefix: vArray, vWord, vName, etc…
wchar_t* vVowel[5] = { L'a', L'e', L'i', L'o', L'u' };
int vYear[3] = { 2017, 2018, 2019 };
float vPrizes[2] = { 3.25f, 2.5f };
Arrays can also be declared in 2 or more dimensions.
You can note how it is actually an array of arrays:
// [Gender][Number]
wchar_t* vArticle[2][2] =
{
{L"la ", L"las "},
{L"el ", L"los "}
};
Information stored in an array can be accessed this way:
wchar_t sChar_O = vVowel[3];
wchar_t sArticle_Las = vArticle[0][1];
Because strings are arrays of characters, characters can be extracted from a string the same way:
wchar_t sHouse = L"House;
char CharU = sHouse[2];
Common C language FAQ:
&& means AND
|| means OR
++var is the same as var + 1
--var is the same as var - 1
// Are used to add comment lines
== is an EQUAL test: 1 == 1 is true 1 == 2 is false. Can't be used with strings!
= means assignment: var = 1 means var takes value 1. Can't be used with strings!
All languages common functions:
Param functions are the script inputs with information coming from the game to be used in translations.
Param functions are the same for any language and are provided by us.
You will find them at the beginning of any script and you should never change them.
-
ParamStr( sWord );
sWord is a simple string input parameter. Usually a static word with no added information. -
ParamStrArray( vWord );
vWord is an array of strings, usually containing word definitions that can include information about gender, number, and any available case for that word following the word definitions specified in your language definition file. -
ParamInt( nNumber );
A integer number without decimals, can be a year, a quantity, a value, etc. -
ParamFloat( nNumber );
A float number, which means a number including decimals.
String functions:
Besides any other custom auxiliary function you may add to your language definition file these are the basic ground functions we provide to allow you to format your sOut translated text.
-
StrAdd( sString, sString1 );
Adds sString1 at the end of sString.
As translator you will be using this one like a lot!
Note that numbers are not strings, so AddInt, AddUint and AddFloat need to be used to concatenate number values.//Example 1:
// If sOut == L"The"
StrAdd( sOut , L"house");
// Now sOut == “The house”//Example 2:
// If sOut == L"The"
// and sString == L"house"
StrAdd( sOut , sString );
// Now sOut == “The house”//Example 3:
// If sOut == L"The"
// and House() is a function returning L"house"
StrAdd( sOut , House() );
// Now sOut == “The house” -
IntAdd( sString, nNumber );
Adds the integer nNumber as a string at the end of sString.
Integers are used when the value has no decimals and can be negative.//Example:
// If sOut == L"I have "
IntAdd( sOut , -3 );
// Now sOut == “I have -3” -
FloatAdd( sString, nNumber, nDec );
nDec is an integer number specifying the numbers of decimals to be used.
Adds the float number nNumber as a string at the end of sString.
Floats are numbers that include decimals. they are written with a final f in code
They can be positive and negative.//Example:
// If Out == L"I have "
FloatAdd( sOut , -3.1416f, 2 );
// Now sOut == “I have -3.14” -
StrEqual( sString0, sString1, nChars );
nChars is an integer number.
Returns true if the first nChars of sString0 are equal to the first nChars of sString1
If you want to check the entire string use nChars = 0;//Example:
// If sString0 == “Car” and sString1 == “Caption”
StrEqual( sString0, sString1, 0 );
// returns false, but
StrEqual( sString0, sString1, 2 );
// returns true because both strings start with “Ca”
// and only the first 2 characters are compared. -
StrLength(sString);
Returns the number of characters in sString//Example:
// If sString== “the”
StrLength(sString);
// will return 3 -
StrCap(sString);
Capitalise the first sString character.//Example:
// If sOut == “the”
StrCap(sOut);
// Now sOut == “The” -
StrUpper(sString);
Make all characters in sString lower case.//Example:
// If sOut == “TeA TiMe”
StrUpper(sOut);
// Now sOut == “TEA TIME” -
StrLower(sString);
Make all characters in sString lower case.//Example:
// If sOut == “TeA TiMe”
StrLower(sOut);
// Now sOut == “tea time”