• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

README_all_translators.mdH A D03-Jul-20217.6 KiB14391

README_all_translators.md

1# Instructions for Cataclysm-DDA translators
2
3* [Translation file format](#translation-file-format)
4* [Translation file header](#translation-file-header)
5* [Format strings and newlines](#format-strings-and-newlines)
6* [Special tags in strings](#special-tags-in-strings)
7* [Plural forms](#plural-forms)
8
9## Translation file format
10
11Translations are stored in ".po" files, named with a language code specific to each language and country. So for example the translations for the Spanish spoken in Spain would be found in "es_ES.po" and for Spanish spoken in Mexico would be found in "es_MX.po".
12
13It is a plain-text filetype, so you can edit it however you choose, but translators often prefer to use purpose-built translation editors (such as Poedit from poedit.net), or web-based translation tools (such as translations.launchpad.net).
14
15The format of ".po" files is a list of entries, with the english phrase to be translated, followed by the local translation. The english phrase is on the line or lines beginning with `msgid`, and the translated phrase goes on the line or lines beginning with `msgstr`.
16
17Before the `msgid` line there will be a comment line indicating where in the source code the word or phrase came from. This can often help when the meaning of the english is not obvious. There may also be comments left by the developers to make translation easier.
18
19Most entries will look something like this:
20
21    #: action.cpp:421
22    msgid "Construct Terrain"
23    msgstr "niarreT tcurtsnoC"
24
25The english phrase here is "Construct Terrain", and it comes from line 421 of the file "action.cpp". The example translation is just a reversal of the english letters. With this, in stead of "Construct Terrain", the game will display "niarreT tcurtsnoC".
26
27Another exmple is:
28
29    #: action.cpp:425 defense.cpp:635 defense.cpp:701 npcmove.cpp:2049
30    msgid "Sleep"
31    msgstr "pleeS"
32
33This is similar to the last example, except it is a more common phrase. It is used in the files action.cpp, defense.cpp (twice) and npcmove.cpp. The translation will replace every usage.
34
35
36## Translation file header
37
38The header at the top of the ".po" file is the only part that differs from the comment/msgid/msgstr format.
39
40If you are working on an already established translation you will not have to modify it.
41
42For a new translation, it should be mostly set up for you, either by the editor you are using or by the `msginit` program which is the recommended way of initializing a translation (see TRANSLATING.md).
43
44If you are starting from another translation file however, you might need to change a few things. Just fill it in as best you are able.
45
46The header will look something like:
47
48    # French translations for Cataclysm-DDA package.
49    # Copyright (C) 2013 CleverRaven and Cataclysm-DDA contributors.
50    # This file is distributed under the same license as the Cataclysm-DDA package.
51    # Administrator <EMAIL@ADDRESS>, 2013.
52    #
53    msgid ""
54    msgstr ""
55    "Project-Id-Version: 0.7-git\n"
56    "Report-Msgid-Bugs-To: http://github.com/CleverRaven/Cataclysm-DDA\n"
57    "POT-Creation-Date: 2013-08-01 13:44+0800\n"
58    "PO-Revision-Date: 2013-08-01 14:02+0800\n"
59    "Last-Translator: YOUR NAME <your@email.address>\n"
60    "Language-Team: French\n"
61    "Language: fr\n"
62    "MIME-Version: 1.0\n"
63    "Content-Type: text/plain; charset=UTF-8\n"
64    "Content-Transfer-Encoding: 8bit\n"
65    "Plural-Forms: nplurals=2; plural=(n > 1);\n"
66
67If you are starting a new translation, or you are in charge of the existing translation, it is helpful if you include your name and e-mail address so that you can be contacted with any questions or issues regarding the translation.
68
69The only important part that cannot be easily filled out manually is the `Plural-Forms` section. It determines how different numbers of things are handled in your language. More on that later.
70
71
72## Format strings and newlines
73
74Some strings will have special terms such as `%s`, `%2$d` and `\n`.
75
76`\n` represents a linebreak. Mostly these are unnecessary as the code wraps lines where it can, but sometimes these are used for placing things on different lines. Just use `\n` in your translation wherever a new line should go.
77
78`%s` and other similar terms are replaced with something else when the game is running. You might need to move them around, depending on the translation. It is important that every term beginning with `%` is kept in the translation.
79
80Here is an example which replaces a `%d` with a number:
81
82    #: addiction.cpp:224
83    #, c-format
84    msgid ""
85    "Strength - %d;   Perception - 1;   Dexterity - 1;\n"
86    "Depression and physical pain to some degree.  Frequent cravings.  Vomiting."
87    msgstr ""
88    ";1 - ytiretxeD   ;1 - noitpecreP   ;%d - htgnertS\n"
89    ".gnitimoV  .sgnivarc tneuqerF  .eerged emos ot niap lacisyhp dna noisserpeD"
90
91Here it is important that the `%d` was not reversed, and that the `\n` remained at the end of the line. In this case, `%d` will be replaced with the character's strength modifier when the message is displayed.
92
93In some cases it might be necessary to change the order of terms. This can confuse the game. If the order of the `%` terms changes, you must add numbers to all of them, so that the game knows which was which. Some strings will already have these numbers, but some might not.
94
95As an example, if there is a string with `%s shoots %s!`, it might change in translation. Perhaps it will become something like `%s is shot by %s!`. But now it is the wrong way around, the shooter has swapped with the shootee.
96
97In this case, each `%s` should be numbered with a digit (1-9) then a dollar sign ($) between the `%` and the `s`. For example `%1$s shoots %2$s!` would be equivalent to `%s shoots %s!`. So the example translation above could be `%2$s is shot by %1$s!`, and this would work correctly.
98
99The game can figure out these `%1$s` `%2$s` parameters automatically, but you must make sure that (A): all of the `%` terms in the translation are numbered; and (B): the numbers are correct in terms of the original ordering in the english text.
100
101For example:
102
103    #: map.cpp:680
104    #, c-format
105    msgid "%s loses control of the %s."
106    msgstr "%2$s eht fo lortnoc sesol %1$s"
107
108would be displayed in-game as `kcurt eht fo lortnoc sesol liagibA`, assuming `Abigail` was driving a `truck`.
109
110
111## Special tags in strings
112
113Some strings in the translation may have special tags in front of or inside them. These tags should be left as-is, and only the rest of the string translated.
114
115For example, the NPC and city names from "data/raw/names.json" are prefixed with `<name>` so as to avoid conflicts with words (such as `Wood` the material, and `Wood` the last name). For these, the `<name>` part should be left in.
116
117For example:
118
119    #. ~ proper name; gender=female; usage=given
120    #: lang/json/json_names.py:6
121    msgid "<name>Abigail"
122    msgstr "<name>liagibA"
123
124Names also have a comment above them, indicating what the name is used for in-game. In this case, `Abigail` is a possible first name for a female NPC.
125
126
127## Plural forms
128
129Many languages use different terms for things depending on how many of them there are. These are supported using plural forms, defined by the `Plural-Form` line in the ".po" file header.
130
131For these, there will be multiple `msgstr` lines, intended for the different forms depending on number. The game will automatically choose the correct form depending on the number of things.
132
133For example:
134
135    #: melee.cpp:913
136    #, c-format
137    msgid "%d enemy hit!"
138    msgid_plural "%d enemies hit!"
139    msgstr[0] "!tih ymene %d"
140    msgstr[1] "!tih seimene %d"
141
142Here the first entry is for when there is only one `enemy`, the second is for when there are more than one `enemies`. The rules differ wildly between languages.
143