2008-08-18
2013-10-19
In some pieces of software, translating texts can be a tedious task of associating texts for cryptic symbols, editing scripts by hand... This is not the case here! We're using the state-of-the-art gettext translation system, as well as the Poedit graphical interface.
Links:
Let's begin with something small, to understand the translation system :)
Here's the result with the Polish, Macedonian and French translations:
The general principle is to translate a set of texts or strings. The set of strings makes a catalog. The catalog is a .po file, which is then opened by DFArc to translate the interface. This way the strings are separate from the program itself.
Even more interesting: you can automatically extract strings from the DFArc source code, and also merge them in an existing translation, only updating what changed since the previous release.
For example, let's begin a new catalog for Italian. Here's the main window, MS Windows and GNU/Linux versions:
First, install Poedit on your system: http://www.poedit.net/download.php.
Note: I'm going to use the GNU/Linux English version in the screenshots, but it is identical on other platforms and languages.
Now you select File > New catalog from POT file...
POT means PO Template: it contains the DFArc strings without translations yet. Download and open dfarc.pot.
You then specify what language you're going to translate (leave out the other fields for now):
Then save your catalog, preferably using its language code. See the gettext documentation for a list of codes.
You then can edit the catalog.
%s and other %XXX are standard marks that are
replaced by filenames or numbers by DFArc. You need to copy them
unmodified in your translation (technical note: they
are printf
formats from the C programming language).
Here's my up-to-date French catalog:
When you press Save, Poedit will create a .mo file, which is the .po converted to binary format (more efficient), in the same directory. That's what you'll give DFArc.
Under GNU/Linux: place your xx.mo file
in /usr/local/share/locale/xx/LC_MESSAGES/dfarc.mo
,
replacing xx by your language code.
Under MS Windows: place your xx.mo file
in po\xx\LC_MESSAGES\dfarc.mo
,
replacing xx by your language code, in the same directory
than DFArc. For example, my French (fr) catalog is in C:\Program
Files\Dink Smallwood\po\fr\LC_MESSAGES\dfarc.mo
.
Note: the current language is automatically detected, using your
operating system. GNU/Linux users may type LANG=xx
dfarc
to use a particular language once.
Note that this only works with the new DFArc v3 (DFArc2 doesn't use gettext). Download the current version here for MS Windows (other versions).
That's it for today! Now you know the basics for translating DFArc. There is more to try, including merging a newer POT file with your translations, browsing the source code to see a string in context (for better understanding), update fuzzy (slightly changed) translations, plural forms... More later!
FreeDink works in collaboration with the Translation Project (dfarc page).
We'll include your translation in the next release :)
With the FreeDink game engine, you can translate the game using the same PO translation system.
It is bigger: DFArc contains around 130 strings, the game story has around 2200. However, the game story is mostly dialogs, which is faster to translate. Count between 10 and 15 hours to translate the whole game.
The game story consists of about 380 script files:
See http://translationproject.org/domain/dink.html for the .pot template file (click on "The current template for this domain is dink-something.pot".
Install FreeDink, and place your translations in
dink/l10n/xx/LC_MESSAGES/dink.mo
. The engine
will automatically translate the game! The game is already translated
in French, Dutch, German, Danish,
and others
are in progress.
It's also planned to allow language-specific files in
dink/l10n/xx.
The system can be used for D-Mods too. See for example island-fr.po, a French version of Mystery Island.
(defun po-ispell-next () "Search the next entry to check" (po-find-span-of-entry) (let ((here (point))) (goto-char po-end-of-entry) (if (re-search-forward po-any-msgstr-block-regexp nil t) (progn (goto-char (match-beginning 0)) (po-current-entry) t) nil))) (defun po-ispell () "Check the spelling of the po file" (interactive) (save-excursion (save-restriction (let ((buffer-read-only po-read-only)) (po-first-entry) (while (po-ispell-next) (po-find-span-of-entry) (ispell-region (+ po-start-of-msgstr-block 6) po-end-of-entry))))))(updated from this post)
pospell -n filename.po -p ispell -- %f