Format of langfiles
From OpenTTD
Contents |
[edit] General Layout
Each entry of the langfile consists of exactly one line.
An entry is either translation, a pragma or a comment.
If you use the web translator tool, you only see translations.
The encoding is UTF-8.
[edit] Translations
Translations consist of a key and a translation. They are separated by a colon (:).
[edit] Keys
The key can only contain uppercase letters, numbers and the underscore (_). Each key starts with "STR_" followed by one or more well describing words.
STR_MAPSIZE STR_000F_PASSENGERS STR_SORT_BY_DATE STR_0196_SHOW_LAND_OWNERS_ON_MAP
[edit] Translations
Using curly braces {}, special commands can be inserted into the translations, which are substituted either by strgen or while the string is drawn on the screen.
| Command | Replaced by |
|---|---|
| {} | Linebreak |
| {{} | Opening curly brace |
| {UPARROW} | ↑ |
| {DOWNARROW} | ↓ |
| {SMALLUPARROW} | Small arrow up |
| {SMALLDOWNARROW} | Small arrow down |
| {RIGHTARROW} | → |
| {NBSP} | Non-Breakable space |
| {CENT} | ¢ |
| {EURO} | € |
| {POUNDSIGN} | £ |
| {YENSIGN} | ¥ |
| {COPYRIGHT} | © |
| {REGISTERED} | ® |
| {CHECKMARK} | √ |
| {CROSS} | Big cross |
| {TRAIN} | Symbol for train |
| {LORRY} | Symbol for lorry |
| {BUS} | Symbol for bus |
| {PLANE} | Symbol for airplane |
| {SHIP} | Symbol for ship |
| Command | Replaced by |
|---|---|
| {TINYFONT} | text is drawn in smaller font |
| {BIGFONT} | text is drawn in bigger font |
| {SETX nn} | text starts at position nn |
| {SETXY nn mm'} | text starts at position nn/mm |
| {BLUE} | text is drawn in blue |
| {SILVER} | text is drawn in silver |
| {GOLD} | text is drawn in gold |
| {RED} | text is drawn in red |
| {PURPLE} | text is drawn in purple |
| {LTBROWN} | text is drawn in light brown |
| {ORANGE} | text is drawn in orange |
| {GREEN} | text is drawn in green |
| {YELLOW} | text is drawn in yellow |
| {DKGREEN} | text is drawn in dark green |
| {CREAM} | text is drawn in cream |
| {BROWN} | text is drawn in brown |
| {WHITE} | text is drawn in white |
| {LTBLUE} | text is drawn in light blue |
| {GRAY} | text is drawn in gray |
| {DKBLUE} | text is drawn in dark blue |
| {BLACK} | text is drawn in black |
parameter replacement is done in the game, filling placeholder in the strings with names, numbers or strings.
| Command | Replaced by |
|---|---|
| {COMMA} | a number with comma |
| {NUM} | a signed number |
| {STRING} | a single string |
| {STRINGn} | a string, which in turn consumes n parameters (1<=n<=5) This is a special case, only to be used in english.txt. In any other language, {STRING} should be used instead |
| {COMPANY} | company name |
| {PLAYERNAME} | player name |
| {VEHICLE} | vehicle name |
| {TOWN} | town name |
| {STATION} | station name |
| {WAYPOINT} | waypoint name |
| {INDUSTRY} | industry name (e.g. London Coal Mine) |
| {CARGO} | cargo in long form: number, unit and type (e.g. 12 tons of steel) |
| {SHORTCARGO} | cargo in short form: only number and unit (e.g. 12 tons) |
| {VOLUME} | a number extended by litres |
| {VELOCITY} | a number with the unit of speed (e.g. 120 mph) |
| {CURRENCY} | a number extended with currency symbols |
| {CURRENCY64} | a 64-bit number extended with currency symbols |
| {CURRCOMPACT} | a compacted number extended by currency symbols |
| {CURRCOMPACT64} | a compacted 64-bit number extended by currency symbols |
| {DATE_TINY} | a date in the format dd-mm-yyyy (e.g. 25-12-1975) |
| {DATE_SHORT} | a date in the form mmmm yyyy (e.g. December 1975) |
| {DATE_LONG} | a date in the format dd mmm yyyy (e.g. 12th Dec 1975) |
| {STATIONFEATURES} | small icons of the supported vehicle types of a specific station |
| {REV} | the openttd revision number |
| {SKIP} | nothing (removes one parameter from the parameter list without printing it) |
| {P * * * *} | plural form (* stands for any string that can be quoted with " character, there can be up to 4 *s) See List of plural-types |
| {G ...} | *see below* |
[edit] Changing Word Order
Parameter replacements can be made swappable too. This will allow one parameter that is usually at position 0 (as in : the first one ) in the translated string to be used in fact at position 1, thus swapping place with no 1.
As an example : STR_INDUSTRY_PROD_GOUP.
In English, the string reads as "{BLACK}{BIGFONT}{STRING} production at {INDUSTRY} increases {COMMA}%!"
In Finnish, same string is now "{BLACK}{BIGFONT}{1:INDUSTRY} tuottaa {0:STRING} {2:COMMA}{NBSP}% entistä enemmän!"
[edit] Cases
After each key, there can be a custom suffix case separated by the period (.). The case must be defined first at the beginning of the file by ##case pragma.
In the following example from the Czech language file, you can see how to define the cases. The Czech language has 7 cases and there is an extra "case" for capitalizing cargo name in the Subsidies dialog.
##case nom gen dat acc voc loc ins big
STR_0011_MAIL :pošta STR_0011_MAIL.big :Pošta STR_0011_MAIL.gen :pošty
The generic usage of cases is to append a period and the case name to the STRING command. In the paragraph "Dotace dopravy {STRING.gen} z{NBSP}{STRING} do {STRING} nebude dále nabízena." a genitive case is necessary.
STR_202E_OFFER_OF_SUBSIDY_EXPIRED :{BLACK}{BIGFONT}Nabídka dotace přepravy vypršela:{}{}Dotace dopravy {STRING.gen} z{NBSP}{STRING} do {STRING} nebude dále nabízena.
STR_2027_FROM_TO :{ORANGE}{STRING.big} z {STRING} do {STRING}
[edit] Plural form
[edit] Introduction
In most languages singular and plural forms are a bit different. Every word may be divided into two parts - one part does not change in both singular and plural form, but the second part differs in singular and plural. Let's call them core and suffix.
Let's take basic example in English language, which is basic because it has two forms: singular and plural.
There is "1 train", but there are "2 trains".
Now, let's divide this word into part that does not change and part that changes:
- Core: "train"
- Suffix for singular: ""
- Suffix for plural: "s"
[edit] Writing the string
As I said before, there are two forms in English language.
The basic structure for plural form in English iscore{P suffix1 suffix2}where suffix1 is suffix for signular and suffix2 is suffix for plural.
Keep in mind, that plural forms work only if there is proper parameter in the string.
{COMMA} and {NUM}, along with other numeric params work well in determining plural form.
Let's make a string that displays number of lamps in the room. Form of "lamp" would depend on supplied amount via {NUM} parameter.
[edit] Example
STR_SENTENCE : I have {NUM} lamp{P "" s}
Do you see the core? Yes, it is the word lamp.
Later you see {P. This is the indicator that suffixes will come next.
"" means there is no suffix. OpenTTD needs to know that - If there is no suffix, just write two quotation marks. So this is the first suffix, which will be used when {NUM} is equal to 1
s is the second suffix. This one will be displayed when {NUM} is bigger than 1.
Let's proceed to more advanced plural forms. Let's take mouse. Its plural form is mice.
First of all, imagine the sentence with different parameters.
- 1 - Mum, there is 1 mouse in the room!
- 3 - Mum, there are 3 mice in the room!
- 23 - Mum, there are 23 mice in the room!
When you are ready, you can write the string.
STR_SENTENCE : Mum, there {P 0 is are} {NUM} m{P ouse ice} in the room!
As you may have noticed, the first {P contains an extra number before the suffixes. This is used to specify which parameter should be used to determine the plural form. When no number is given, the previous parameter is used, but in this case there is no previous parameter, that's why we need to specify it.
Whoever added this template didn't specify what was to be done, so it should be removed or updated with the correct action.
check if it is not wrong
[edit] OpenTTD usage
Now you understand basics of plural forms. Let's take some example from English translation.
STR_QUANTITY_LIVESTOCK : {COMMA} item{P "" s} of livestock
This text is being displayed at stations when there is livestock cargo awaiting.
As you can see, {COMMA} parameter is given. Thanks to that parameter, we can change form of item. Let's see how the string would change when we change supplied parameter.
- 1 - 1 item of livestock
- 4 - 4 items of livestock
- 56 - 56 items of livestock
STR_WAGONS : WagonsNo plural form may be applied here. Wagon{P "" s} will not work here.
Why? Because there is no parameter given.
You can just leave this string as it is.
[edit] Other plural types
Find your language on List of plural-types table below. Languages are being groupped depending on behaviour of words with different amounts.
Suffixes are being ordered ascending, with any other number at end:
- First suffix is always singular.
- Second suffix may be for any other number (English), or depending on your language, for other numbers. For example in Polish language the second form applies for numbers that end with 2, 3 or 4, .but excluding -teen numbers.
- If the second suffix was not for any other number, the third one is for any other number.
Let's take Polish language and invent some dummy string
STR_CARS : {NUM} aut{P o a ""}
Now take a look at description above, and guess how would the string look for {NUM} equal to 1, 2, 5, 13, 23, 38?
- 1 auto (first suffix used)
- 2 auta (second suffix used - number ends with 2, 3 or 4)
- 5 aut (third suffix used - any other number)
- 13 aut (third suffix used - second suffix excludes -teen numbers)
- 23 auta (second suffix used - number ends with 2, 3 or 4)
- 38 aut (third suffix used - any other number)
[edit] Genders
[edit] Introduction
Some languages feature genders. Each noun (like factory, calculator, dragon) has its gender. Adjectives (green, new, beautiful) and sometimes verbs (to fall, to eat) are being affected by gender.
First of all, think of your language's gender. Then, open the Web Translator 2, go to "Manage" page of your language and check the dropdown list of genders. If there are no genders yet, hit "+" button and supply short forms of your genders (m f n for male female neutral is good).
When you've done this, think of strings in OpenTTD that may require genders. News report that new industry is being founded is good, because industry is a noun and some words in the string should change depending on gender.
[edit] Writing the string
To set string's gender, insert {G=*} tag before first word of the string, where * is name of the gender you sent before.
In the string that may change depending on genders, use {G suffix1 suffix2 suffix3} structure, where each suffix corresponds to the right gender (gender order is in the "Manage" section of your language, in the dropdown list)
[edit] Example
I'll use The Latin language in examples, because it is common, and of course, uses genders.
Latin language has three genders, we will call them m, f and n.
Let's guess some nouns we will use in examples.
- puteus m - a well, pit
- officina f - a workshop, factory
- forum n - - an open square, marketplace
Let's take some adjective and find its core and suffixes:
magnus, magna, magnum - large (male, female, neutral)
As you can see, magn is the core, and suffixes are us, a and um respectively for male, female and neutral gender.
And this is how would the example string work:
STR_WELL : {G=m}Puteus
STR_FACTORY : {G=f}Officina
STR_SQUARE : {G=n}Forum
STR_IS_BIG : {STRING} magn{G us a um} est
Do you imagine how will the result look like? Here is the answer:
- Puteus magnus est
- Officina magna est
- Forum magnum est
Again, as with plural form, if there is no suffix, write "". Use always as many suffixes as there are genders.
[edit] Advanced use
{G...} tag bases on gender of {STRING} after the tag. However, if you need to change suffix of a word which is after {STRING} (before tag), you have to write ID of string you want to retrieve gender from. This may sound clumsy, so let's take a look at example:
{BLACK}{BIGFONT}Now{G y a e} {STRING} został{G "" a o} posadzon{G y a e} blisko {TOWN}!
Second and third {G...} will not work, because there is no {STRING} after them to get gender from.
We want to retrieve gender from first (and the only one) {STRING} tag. First tag has ID=0, second tag has ID=1 and so on. Here is how to do that:
{BLACK}{BIGFONT}Now{G y a e} {STRING} został{G 0 "" a o} posadzon{G 0 y a e} blisko {TOWN}!
Adding IDs resolved the problem. The string works as expected.
) In the following example we use two genders: male and female
Mis{G ter s} {STRING} is shocked by h{G 0 is er} grand{G 2 son daughter} who flamed mis{G ter s} {STRING} yesterday. The bad {G boy girl}'s name is {STRING}
Now I'll explain why some {G...}'s have numbers and other do not:
- First, fourth and fifth do not have number, because they fetch gender of next string (default behaviour)
- Second and third do have number, because they fetch gender of a string that is not after the tag. We need to tell game engine which {STRING}'s gender we want to take. The first number is zero, because it's ID of first {STRING}. The next number is two, because it's ID of third {STRING}
[edit] OpenTTD usage
Yeah,Whoever added this template didn't specify what was to be done, so it should be removed or updated with the correct action.
write it soon.
[edit] Pragmas
Pragmas start with two hash signs (#).
| Name | Function |
|---|---|
| name name | Name of the language in English |
| ownname name | Name of the language in the language itself |
| isocode code | ISO code for the language (eg. de) |
| plural number | Type of the plural forms |
| gender up to 8 gender names | defines genders |
| case up to 50 case names | define cases |
| id hexnumber | Next string id starts at hexnumber |
| Nr. | Description | |
|---|---|---|
| Used for | ||
| 0 | Two forms, singular used for one only | |
| Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish, Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto | ||
| 1 | Only one form | |
| Hungarian, Japanese, Korean, Turkish | ||
| 2 | Two forms, singular used for zero and one | |
| French, Brazilian Portuguese | ||
| 3 | Three forms, special case for zero | |
| Latvian | ||
| 4 | Three forms, special case for one and two | |
| Gaelige (Irish) | ||
| 5 | Three forms, special case for numbers ending in 1[2-9] | |
| Lithuanian | ||
| 6 | Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4] | |
| Croatian, Czech, Russian, Slovak, Ukrainian | ||
| 7 | Three forms, special case for one and numbers ending in 2, 3, or 4, except those ending in 1[2-4] | |
| Polish | ||
| 8 | Four forms, special case for one and all numbers ending in 02, 03, or 04 | |
| Slovanian |
##name English ##id 0x1000
[edit] Comments
Comments start either with one or more than two hash signs (#) or with a semicolon (;). Empty lines are ignored too.
# Ignore #### Ignore this ;and this too
