Internationalization: Difference between revisions
update |
add more info |
||
Line 64: | Line 64: | ||
* re-generate the language files with '''perl devel/gen_lang.pl''' | * re-generate the language files with '''perl devel/gen_lang.pl''' | ||
Note that if the translations for the new strings (or any other string) are missing, the script will substitute the English variant - so you should always have at least the English variant. | |||
The other translations are optional, but if they are added later, you need to re-run '''perl devel/gen_lang.pl'''! See also the next point: | |||
=== Missing Translations === | === Missing Translations === | ||
Line 87: | Line 81: | ||
to each language variant where the string is unchanged after translation. | to each language variant where the string is unchanged after translation. | ||
Since it can be a bother to ask translators for a new string translation every other day, the current solution is to gather strings for a while, then regenerate the missing_xyz.txt files, and then ask the translators for a translation. | |||
See also the [[I18N - List of TDM translators|List of TDM translators]]. | |||
=== Relocating String IDs === | |||
{{infobox|Note: Relocation of string IDs can only be done either before release, or when it is clear that this string is not used by any FM, otherwise you break FMs!}} | |||
perl devel/rename_string.pl FIRSTOLDID FRISTNEWID COUNT | |||
Example: | |||
perl devel/rename_string.pl 2236 2298 2 | |||
=== GUI === | === GUI === |
Revision as of 16:53, 23 October 2011
This article deals with the localisation/translation of both TDM itself, as well as Fan Missions.
I18N, L10N?
I18N stands for internationalisation (the 18 means there are 18 letters missing between I and N), and L10N stands for localisation.
For Users
You can switch the language of TDM in the Settings menu under Video, General. The language is stored in the CVAR tdm_lang. Ignore sys_lang.
Switching the language does not require a newstart, except for some languages like Russian. There the game will inform you that you need to restart it manually, or the display will not look correct.
Changing the language will change the language of the HUD, as well as the inventory immidiately. It can also be done during a mission.
See the list of already internationalized FMs and their status.
For Mappers
As a mapper, you want to reach an audience as wide as possible with your FM. One way is to provide alternative language versions of your map. There are two ways that can be achieved:
- You can ignore the issue, and hope that somebody else modifies your FM and provides a translation. The past shows that the changes that someone does this are slim, tho. Only a handful of FMs were every translated, most of them only into one other languages. That is because modifying and translating an FM are quite a lot of work, and translators would rather just translate things than to muck around with your PK4 file.
- You can (from v1.07 on) build in support for translation from the beginning, and make the work for translators easier.
The second point can achieved in two ways:
- You build the FM with hard-coded strings like 'Silver Key', and then use I18N.pl to transform the FM into a package that can have external dictionaries. That might be easier to work with in DR (as DR itself has no support for dictionaries yet), but the script might not be 100% correct and you need to manually help it out.
- You build your FM with string templates like "#str_12345" instead of hard-coded names, and supply an external dictionary with these strings.
FM specific dictionaries
Please see the main article about about translating FMs for details.
Inventory Item Names with multiple lines
If you have an inventor item name which is very long, you can insert \n to split it up into two (but not more!) lines:
"#str_20000" "This is a very very\nlong item name."
You should try in the game to see how it looks, so that both lines are roughly the same length.
For Developers
CVAR tdm_lang
The D3 CVAR sys_lang is restricted to a few hard-coded values, and is thus not usable. We have added a new CVAR tdm_lang, which contains the current language as English lower-case string, e.g. "english", "german", "portuguese" etc. This variable is controlled by the GUI via a call back into the SDK code, which switches the language underneath, and also reloads the GUI.
Code
The main translation object is of the class CI18N (which is short for "Class Internationalization") and lives in Darkmod/I18N.cpp and Darkmod/I18N.h.
New Strings
If you need to add a new string, follow these steps:
- search for a fitting, free ID in strings/all.lang.
- Add your string there. If possible, add any translation you can, or ask the translators to translate it for you.
- re-generate the language files with perl devel/gen_lang.pl
Note that if the translations for the new strings (or any other string) are missing, the script will substitute the English variant - so you should always have at least the English variant.
The other translations are optional, but if they are added later, you need to re-run perl devel/gen_lang.pl! See also the next point:
Missing Translations
The following will generate files called "missing_language.txt" in the darkmod directory:
perl devel/gen_lang.pl --missing
Note that the script can no differentiate between a string that was not translated, and a string that is the same even after translation. An example is "Normal" in English, and German. This will be listed as missing string in missing_german.txt.
To avoid that, add the following comment:
"#str_03005" "Normal" // stays the same
to each language variant where the string is unchanged after translation.
Since it can be a bother to ask translators for a new string translation every other day, the current solution is to gather strings for a while, then regenerate the missing_xyz.txt files, and then ask the translators for a translation.
See also the List of TDM translators.
Relocating String IDs
perl devel/rename_string.pl FIRSTOLDID FRISTNEWID COUNT
Example:
perl devel/rename_string.pl 2236 2298 2
GUI
To work around the choiceDef bug, two new main menu commands have been added, called "initChoice" and "stepChoice". These two take 3 arguments each:
- the CVAR name
- the labels for each choice (should be in the form '#str_01234" to make it translatable)
- the values for each choice (usually a hard-coded list like '0;1')
In addition to these, a few GUI #defines where added that make it easier to add a new choice def. Here is how it looked before:
choiceDef PostProcessing { rect SETTINGS_X_OFFSET, 54, 80, 14 choices "#str_07300" // disabled, enabled values "1;0" cvar "r_postprocess" choiceType 0 font SETTINGS_FONT textscale SETTINGS_FONT_SCALE_CHOICE textalign 1 textaligny 0 forecolor SETTINGS_FONT_COLOUR onAction { set "cmd" "play sound/meta/menu/mnu_select" ; resetTime "UpdateBloomSliderVisibility" 0; } }
And here is how it has to look now:
windowDef PostProcessing { rect SETTINGS_X_OFFSET, 54, 80, 14 text "gui::r_postprocess_text" CHOICE_INIT "initChoice 'r_postprocess' '#str_07300' '1;0'" } CHOICE_STEP "stepChoice 'r_postprocess' '#str_07300' '1;0'"; resetTime "UpdateBloomSliderVisibility" 0; } }
Notes:
- use windowDef, not choiceDef, or the GUI will crash upon load.
- the text variable has to be in the format "gui::cvarname_text" (e.g. the CVAR with "_text" appended)
- The lines for "CHOICE_INIT" and "CHOICE_STEP" must end with a "}".
- The secondary action in CHOICE_STEP (resetTime in the example above) is optional.
Known bugs
Sadly, there are quite a lot of limitations in the D3 SDK that prevent a few things from fully working. Once D3 goes open source, these things will be fixed, in the meantime we hope that you can live with the quirks:
- Doom3 does not support the character 0xFF in fonts rendered, but this character is used f.i. in Russian. To work around this, the character 0xFF is moved to 0xB& during loading of dictionaries. The russion font then simply contains a character 0xB6 with the proper image in place.
- choiceDefs do not properly display choices with high-bit characters. There exist two new menu commands and a few #defines to work around this, see the GUI section above.
See Also
- I18N - Main article
Translation resources
- The charset TDM fonts use
- I18N.pl - a script to transform a FM into a mission and I18N data
- Bug Tracker entry #2779
- Text Decals for Signs etc.
- Fonts in TDM
- Font Conversion & Repair - with links to ExportFontToDoom3, Q3Font, Refont, and Font Patcher
Overview of translations
- I18N Status - Which FMs are translated into which language (not entirely up to date)
- Translating FMs
- List of translators
- Translator's Guide
Translation discussions