User Tools

Site Tools


Action disabled: index
develop:translations-en

Translations

Info

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

Files

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"?>
<Messages>
  <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"/>
  </Msg>
</Messages>
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:
Rocrail/unxgen/rocgui/res/messages.c

#ifdef __cplusplus
  extern "C" {
#endif
const char messages[] = {
60,63,120,109,108,32,118,101,114,115,105,111,110,61,34,49,46,48,34,32,101,
110,99,111,100,105,110,103,61,34,85,84,70,45,56,34,32,115,116,97,110,100,
97,108,111,110,101,61,34,121,101,115,34,63,62,10,60,33,45,45,10,32,82,111,
...
62,10,0
};
#ifdef __cplusplus
  }
#endif

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 Launchpad.net as template for translations.
The only manual edit is the pot header:

# ?.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <support@rocrail.net>, 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 <support@rocrail.net>\n"
"Language-Team: English <EN@li.org>\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