Формат lang-файлов
/File/en/Translation.png
Эта статья переводится с английского языка на русский: en/Archive/Source/OpenTTDDevBlackBook/Format of langfiles.
Процент: 1%
  
Пожалуйста, помогите улучшить перевод.
  • Используйте руководство по стилю для правильного изложения перевода.
  • Помните, что необходимо удалить данный шаблон, когда статья будет полностью переведена.

Contents

Общая информация

Каждая запись в языковом файле состоит из одной строки и является либо переводом, либо управляющей конструкцией, либо коментрием.

Если вы используете WebTranslator3 (en), то будете видеть только записи с переводом.

Кодировка текста в языковом файле: UTF-8.

Переводы

Перевод состоит из ключа и собственно перевода, разделенных двоеточием (:).

Ключи

Имя ключа состоит только из букв верхнего регистра, чисел и знака подчеркивания (_). Каждый ключ начинается с префикса "STR_", за которым следует одно или несколько слов, лаконично описывающих суть данной записи языкового файла. Например:

STR_MAPSIZE
STR_000F_PASSENGERS
STR_SORT_BY_DATE
STR_0196_SHOW_LAND_OWNERS_ON_MAP

Перевод

Кроме текста перевод может содержать специальные команды, которые помещаются в текст при помощи фигурных скобок. Эти команды поддерживаются и обрабатываются как утилитой strgen, так и при выводе строки на экран в процессе игры.

Замена символов
Команда Заменяется на
{} Перенос строки
{{} Открывающая фигурная скобка
{UPARROW}
{DOWNARROW}
{SMALLUPARROW} Уменьшенная стрелка вверх
{SMALLDOWNARROW} Уменьшенная стрелка вниз
{RIGHTARROW}
{NBSP} Неразрывный пробел
{CENT} ¢
{EURO}
{POUNDSIGN} £
{YENSIGN} ¥
{COPYRIGHT} ©
{REGISTERED} ®
{CHECKMARK}
{CROSS} Big cross
{TRAIN} Пиктограмма поезда
{LORRY} Пиктограмма грузовика
{BUS} Пиктограмма автобуса
{PLANE} Пиктограмма самолета
{SHIP} Пиктограмма корабля
Визуальное оформление
Команда Заменяется на
{TINYFONT} установка уменьшенного шрифта
{BIGFONT} установка увеличенного шрифта
{SETX nn} вывод текста, начиная с позиции nn
{SETXY nn mm'} вывод текста с позиции nn (по горизонтали) и mm (по вертикали)
{BLUE} текст выводится цветом blue (синий)
{SILVER} текст выводится цветом silver (серебряный)
{GOLD} текст выводится цветом gold (золотой)
{RED} текст выводится цветом red (красный)
{PURPLE} текст выводится цветом purple (пурпурный)
{LTBROWN} текст выводится цветом light brown (светло-коричневый)
{ORANGE} текст выводится цветом orange (оранжевый)
{GREEN} текст выводится цветом green (зелёный)
{YELLOW} текст выводится цветом yellow (жёлтый)
{DKGREEN} текст выводится цветом dark green (тёмно-зелёный)
{CREAM} текст выводится цветом cream (кремовый)
{BROWN} текст выводится цветом brown (коричневый)
{WHITE} текст выводится цветом white (белый)
{LTBLUE} текст выводится цветом light blue (голубой)
{GRAY} текст выводится цветом gray (серый)
{DKBLUE} текст выводится цветом dark blue (тёмно-синий)
{BLACK} текст выводится цветом black (чёрный)

Подстановка параметров используется в игре для вставки в текст различных игровых данных, других строк языкового файла или чисел.

Подстановка параметров
Команда Заменяется на
{COMMA} Число с точкой
{NUM} Число со знаком
{STRING} Строка
{STRINGn} a string, which in turn consumes n parameters (1<=n<=5)
Эту команду возможно использовать только в файле english.txt. В любом другом языковом файле необходимо использовать команду {STRING}.
{RAW_STRING} Эту команду возможно использовать только в файле english.txt. В любом другом языковом файле необходимо использовать команду {STRING}.
{COMPANY} Имя компании
{PLAYERNAME} Имя игрока
{VEHICLE} Имя транспортного средства
{TOWN} Имя города
{STATION} Имя станции
{WAYPOINT} Имя точки пути
{INDUSTRY} Имя предприятия (например, London Coal Mine)
{CARGO} Груз полностью (например, 12 тонн стали)
{SHORTCARGO} Груз сокращенно (например, 12 тонн)
{VOLUME} Число с добавлением единиц объема (литров)
{VELOCITY} Число с добавлением единиц скорости (например, км/ч)
{CURRENCY} Число с добавлением денежных единиц
{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*

Изменение порядка слов

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!"

/File/en/Klipper.png
Необходимо сделать
Finish and correct this

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}

Plural form

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:

Writing the string

As I said before, there are two forms in English language.

The basic structure for plural form in English is

core{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.

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.

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.

/File/en/Klipper.png
Необходимо сделать
check if it is not wrong

String as number

If the argument that affects a plural form is given as {STRING} then you need to use a special parameter for {P:

Flat area around industries: {ORANGE}{STRING} tile{P 0:1 "" s}

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.

Now let's take a look at string without given parameter.

STR_WAGONS : Wagons

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

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:

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?

Genders

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.

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)

Example

I'll use The Latin language in examples, because it is well-known, 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.

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:

Again, as with plural form, if there is no suffix, write "". Use always as many suffixes as there are genders.

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.

What if there are more {STRING}s? (

/File/en/Klipper.png
Необходимо сделать
I'm not sure, please verify this

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

/File/en/Klipper.png
Необходимо сделать
this section may be clumsy, feel free to improve it

OpenTTD usage

Yeah,

/File/en/Klipper.png
Необходимо сделать
Тот, кто добавил этот шаблон не уточнил, что должно было быть сделано, поэтому он должен быть удален или обновлен после того как будут сделаны нужные правки.

write it soon.

Pragmas

Pragmas start with two hash signs (#).

Pragmas
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

List of plural-types
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

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