Difference between revisions of "Translating"

From UFO:AI
(How to use other fonts)
 
(Generate new language file)
Line 30: Line 30:
 
Coders see our [[Coding/Guidelines]] for more information about this topic
 
Coders see our [[Coding/Guidelines]] for more information about this topic
 
==Generate new language file==
 
==Generate new language file==
Use [http://www.poedit.net/ PoEdit] or any other gettext editor to edit the po-files. Download the latest [http://ufoai.svn.sourceforge.net/viewvc/ufoai/ufoai/trunk/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 [http://ufoai.svn.sourceforge.net/viewvc/ufoai/ufoai/trunk/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 '''ufoai-en.po''' may be easier than looking them up on this wiki.
+
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 [http://ufoai.svn.sourceforge.net/viewvc/ufoai/ufoai/trunk/src/po/ src/po]. If you did your translation, you can submit the po file to our [http://sourceforge.net/tracker/?group_id=157793&atid=805244 patch tracker].
+
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/|src/po}}. If you did your translation, you can submit the po file to our {{http|sourceforge.net/tracker/?group_id=157793&atid=805244|patch tracker}}.
  
To integrate and test the language in the game you also have to edit the '''base/ufos/language.ufo''' (this file may also be in the '''0ufos.pk3''' (Zip-Archive - see [[PK3]]). If you don't have that file nor that '''ufos/''' folder, just create the ufos folder and add a textfile that you name '''your_language.ufo'''. Then it's going to be parsed automatically at game startup.
+
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. '''language.ufo''' needs the following content (example for the japanese language):
+
This new file (resp. {{path|language.ufo}} needs the following content (example for the japanese language):
  
 
  language ja {
 
  language ja {
Line 47: Line 47:
  
 
===How to use other fonts===
 
===How to use other fonts===
If our fonts do not have all characthers 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).
+
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]]
+
{{http|openfontlibrary.org|openfontlibrary.org}}
  
 
==Update existing language-files==
 
==Update existing language-files==

Revision as of 09:40, 23 July 2012

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

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 msgids - 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

Please read the List of msgids very carefully.
This will save you a lot of time when translating the text.

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

We use 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: ..no gettext compiled into this binary you will have to 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 similiar 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 stuctures in .po file to fit your language.

Coders see our Coding/Guidelines for more information about this topic

Generate new language file

Use PoEdit or any other gettext editor to edit the po-files. Download the latest src/po/ufoai.pot - which is a template for new language-files - and load it into PoEdit. Or you may want to start with a renamed src/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 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 src/po/. If you did your translation, you can submit the po file to our http://patch tracker.

To integrate and test the language in the game you also have to edit the base/ufos/language.ufo (this file may also be in the 0ufos.pk3 (Zip-Archive - see PK3). If you don't have that file nor that ufos/ folder, just create the ufos folder and add a textfile that you name your_language.ufo. Then it's going to be parsed automatically at game startup.

This new file (resp. 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 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).

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 SVN up-to-date. You can find all available po files in our svn at src/po .

Linux

To update the ufoai.pot file you enter src/po and type:

make update-po

Compile the language files

General

The language files need to be placed in base/i18n/ (see directory tree). You need to make some directories. Let's take en_GB as example. Create base/i18n/en_GB/LC_MESSAGES and copy 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 ufoai-YourLanguagePrefix.mo file to ufoai.mo. Then follow the steps at general. However, if you have Python installed you may use script compile_po.py from 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