Difference between revisions of "Translating"

From UFO:AI
(Generate new language file)
(cleaned the translation info - most is outdated or useless. will be redone soon)
Line 1: Line 1:
 
<div style="border:2px solid red; background:black; padding:1em;">
 
<div style="border:2px solid red; background:black; padding:1em;">
 
'''Please do not use a normal text editor, use {{http|www.poedit.net/|PoEdit}} instead!'''</div>
 
'''Please do not use a normal text editor, use {{http|www.poedit.net/|PoEdit}} instead!'''</div>
 
Please, whenever you translate and you do not like the original text; correct them on the wiki or voice your opinion on the wiki discussion page for the text.
 
==Information for new translators==
 
The main translation work must be done here in the wiki - see the [[List of msgid]]s - but please read on. New translations are just added via a new column in the tables. In general one can say the ufopedia stuff is translated in the wiki (the majority of the texts) and the menu strings are translated in the po files. So you don't have to touch a po file at all to [[contribute]] with a new translation or to fix spelling bugs in existing translations - just use the wiki.
 
==Story & Equipment related text==
 
<font style="font-size:150%; color:red;">Please read the [[List of msgid]]s very carefully.<br />
 
This will save you a lot of time when translating the text.</font>
 
 
There are some '''msgid'''´s which are not clear by intention. For example '''intro_sentence_1''' or '''assault_txt'''. You can find a list of these [[List of msgid|here]].
 
 
These are just placeholders for even longer texts - e.g. the ufopedia texts, developed here on the wiki. Those msgids should be translated here in the wiki - only use '''poedit''' to translate everything not listed in '''msgid'''-article. We will autoupdate your translations with a script to always keep the current translations. Note: You have to keep the layout of the other translations - use the english original texts by Winter as a template for your new texts. If you would like to translate the game into a new language, feel free to add the language columns as needed (in our '''msgid'''-article). Submit the menu strings and other translations in your po file via the patch tracker on {{http|sourceforge.net/projects/ufoai|sourceforge.net}}. As soon as we have received your po file we will be able to update your wiki texts, too.
 
 
Please, '''do not use''' wiki syntax to create ordered lists, otherwise article will be broken. Also, only '''bold''' formatting will be translated to the game.
 
  
 
==General Information==
 
==General Information==
 
We use {{http|www.gnu.org/software/gettext|gettext}} for our translations.
 
We use {{http|www.gnu.org/software/gettext|gettext}} for our translations.
 
Make sure, that your binary is compiled with gettext support. You can check this by opening the [[console]] - if there is a message like this: <code>..no gettext compiled into this binary</code> you will have to [[coding|recompile]] your binary with gettext-support.
 
 
 
===Plural forms===
 
Gettext can handle plural forms and PoEdit supports it as well. Gettext uses two forms (English) as default but PoEdit have no default and number of forms have to be set (if not, plural is handled like standard message). The right place is Catalog->Settings->Project info->Plural forms. If your language uses only two forms like English (e.g. day/days) fill the field with "nplurals=2; plural=(n != 1);" (without quotes). If your language uses three forms like czech (1, 2 to 4, 5 and more) use something similar to "nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;" (without quotes). If you're unsure what to fill look for any other gettexted project in your language.
 
 
When this field is correct PoEdit shows both forms of original message as "Singular" and "Plural" and below folds each for one form of your language.
 
 
Note: set&save this field BEFORE 'make update-po'. Gettext will generate right structures in .po file to fit your language.
 
 
Coders see our [[Coding/Guidelines]] for more information about this topic
 
==Generate new language file==
 
Use {{http|www.poedit.net|PoEdit}} or any other gettext editor to edit the po-files. Download the latest {{git|src/po/ufoai.pot|ufoai.pot}} - which is a template for new language-files - and load it into PoEdit. Or you may want to start with a renamed {{git|src/po/ufoai-en.po|ufoai-en.po}} and replace the English texts one by one. Be aware that ufoai.pot does not contain the English texts for Ufopedia entries (only placeholders - see '''msgids'''-article), so starting with {{path|ufoai-en.po}} may be easier than looking them up on this wiki.
 
 
Before you try to make a new translation have a look at the list of [[available translations]] and check whether there is maybe already a po file at {{git|src/po}}. If you did your translation, you can submit the po file to our patch tracker.
 
 
To integrate and test the language in the game you also have to edit the {{path|base/ufos/language.ufo}} (this file may also be in the {{path|0ufos.pk3}} (Zip-Archive - see [[PK3]]). If you don't have that file nor that {{path|ufos/}} folder, just create the ufos folder and add a textfile that you name {{path|your_language.ufo}}. Then it's going to be parsed automatically at game startup.
 
 
This new file (resp. {{path|language.ufo}} needs the following content (example for the japanese language):
 
 
language ja {
 
        "_Japanese"
 
        {
 
                ja_JP.UTF-8
 
                ja_JP.utf8
 
        }
 
}
 
 
===How to use other fonts===
 
If our fonts do not have all characters you need, you are able to use your own fonts by translating the [[UFO-Scripts/fonts.ufo|font paths]] in your po file. Just submit the font and your po file (keep in mind, that the font itself has to be released under [[GNU GPL]] or [[Creative Commons]] with no "non-commercial" clause).
 
 
{{http|openfontlibrary.org|openfontlibrary.org}}
 
 
==Update existing language-files==
 
Currently our build system is only able to update the pot-file under Linux. This is why we try to keep the ufoai.pot in [[Getting the source|the repo]] up-to-date.
 
You can find all available po files in our svn at {{git|src/po}}.
 
===Linux===
 
To update the {{path|ufoai.pot}} file you enter {{path|src/po}} and type:
 
make update-po
 
==Compile the language files==
 
===General===
 
The language files need to be placed in {{path|base/i18n}} (see [[directory tree]]). You need to make some directories. Let's take en_GB as example. Create {{path|base/i18n/en_GB/LC_MESSAGES}} and copy {{path|ufoai.mo}} (the compiled po file) to LC_MESSAGES.
 
===Linux===
 
Compile them via poEdit or your gettext editor. You also have the ability to compile them from the commandline. Just type
 
 
make lang
 
 
in trunk.
 
===Windows===
 
Compile them via poEdit or your gettext editor (poEdit: Hit save to compile the mo-file). You have to rename the {{path|ufoai-YourLanguagePrefix.mo}} file to {{path|ufoai.mo}}. Then follow the steps at [[Translating#general|general]]. However, if you have {{http|www.python.org/|Python}} installed you may use script {{path|compile_po.py}} from {{path|src/po}} to automate the task. Just supply it a path to your msgfmt.exe (usually found in poEdit directory).
 
 
python compile_po.py E:\path\to\poEdit\bin\msgfmt.exe
 
 
Also, if you use [[Code::Blocks]], languages will be compiled automatically when you compile the game.
 
  
 
==Links==
 
==Links==
* [[Contribute]]
 
* [[Scripting]] (for marking the strings as being translateable from within script language)
 
 
* {{http|www.loc.gov/standards/iso639-2/php/code_list.php|Language codes}}
 
* {{http|www.loc.gov/standards/iso639-2/php/code_list.php|Language codes}}
 +
 
[[Category:Translating]]
 
[[Category:Translating]]
 
[[Category:Contribute]]
 
[[Category:Contribute]]

Revision as of 14:46, 24 July 2012

Please do not use a normal text editor, use PoEdit instead!

General Information

We use gettext for our translations.

Links