User Tools

Site Tools




Translations at are in the GNU gettext format, but Rocrail has a proprietary XML file containing the languages.


The XML file containing the translations in Rocrail for Rocview is /Rocrail/rocgui/res/messages.xml.

Proprietary XML Format

This is an example with one string:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <Msg id="car" dialog="false" key="">
    <de txt="Wagon"/>
    <en txt="Car"/>
    <nl txt="Wagon" tip="Een wagon."/>
    <sv txt="Car"/>
    <cs txt="Auto"/>
    <fr txt="Car"/>
    <da txt="Car"/>
    <es txt="Car"/>
    <hu txt="Kocsi"/>
    <tr txt="Car"/>
Attribute Description
id Used in the source code to look up a message in the current selected language.
dialog This add three dots to the string for menu's if it will open a dialog.
key Keyboard short cut.
txt The message.
tip Tool tip text.

Conversion from UTF-8 to a byte array

Some compilers can not handle such a long serializes XML as string so it is converted into a constant character array using the rocs xml2cstr utility:

#ifdef __cplusplus
  extern "C" {
const char messages[] = {
#ifdef __cplusplus

Creating a template for GNU gettext

The message.xml is not a template, but can be used as input for it using the rocs lang2po utility:

lang2po -i messages.xml -o messages.pot -template -l en

The messages.pot file can be uploaded to as template for translations.
The only manual edit is the pot header:

# ?.
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <>, 2009.
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Rocrail 1.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-01-26 07:51+0100\n"
"PO-Revision-Date: 2009-04-29 21:15+0000\n"
"Last-Translator: Rob Versluis <>\n"
"Language-Team: English <>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2009-04-29 18:00+0000\n"
"X-Generator: Launchpad (build Unknown)\n"

The template uses the English translation as msgid:

# id="changelang"
#, c-format
msgid "Restart to change language."
msgstr ""

Creating a translation for GNU gettext

This is done with the same utility as for creating the template:

lang2po -i messages.xml -o nl.po -l nl

Check the generated file

With the command

msgfmt -c <file>

the file can be validated before upload to Launchpad.

Importing a translation from GNU gettext

The rocs utility po2lang can import GNU gettext formatted files into an existing rocrail messages.xml:

po2lang -i rocrail-tr.po -o messages.xml -l tr

In this example the Turkish language is imported to the messages.xml.
Existing translations in the same imported language are overwritten.

develop/translations-en.txt · Last modified: 2022/12/15 16:46 by rjversluis