Setting up for Translation Using the Command Line

From Rivendell Wiki

Jump to: navigation, search

This page assumes that you have downloaded the Rivendell source code and unpacked it. See the instructions at the beginning of the Translations page for instructions on how to do this.

Contents

Translation Helper Scripts

The current rdtrans.sh will only do a few things and a patch has been submitted that will make it much easier to do translation. Until it is included with the current packages you can download it and save it in the /rivendell/helpers folder of your Rivendell source code folder. To download and make the new scripts executable run the commands below.

cd /home/rduser/rivendell/helpers 
mv rdtrans.sh rdtrans.sh.old
wget http://ubuntuone.com/p/S2G/rdtrans.sh
chmod +x rdtrans.sh


Environmental variables and translation folder

We can use a script called rdtrans.sh to generate the files we will do our translation in. Before you can use it you need to set up the following environmental variables:

$RD_LANGUAGES

$RD_SOURCE

$RD_SHAREDDIR

For this tutorial we will be using the linux user rduser and a directory called rivendell in the home folder or the Rivendell source code files. Translation files will be in a rdlanguages folder in the home folder.

1) RD_SOURCE - The path to the top of the Rivendell source tree. The folder (called rivendell in our tutorial) where you unpack your archive or checkout (downloaded) the source code. Change the path on the line below to match the folder where you un-archived the source code. Inside this folder will be folders with the names: cae, conf, CVS, debian, docs, helpers, icons, importers and files and several more folders.

export RD_SOURCE=/home/rduser/rivendell

2) RD_LANGUAGES - The path to the top of the languages tree (/home/rduser/rdlanguages in our tutorial). This a working folder for your translation files.Change the path on the line below to where you want your folder of files to translate to be. We will be using the folder name rdlanguages through this tutorial.

export RD_LANGUAGES=/home/rduser/rdlanguages

3) RD_SHAREDDIR - The path to Rivendell's shared data directory /usr/local/share/rivendell by default /usr/share/rivendell on Ubuntu. You will find a number of .qm files it this folder whose name consists of a Rivendell application name and a language code. ie. rdairplay_de_CH.qm for RDAirplay language German for Switzerland.

export RD_SHAREDDIR=/usr/local/share/rivendell

or on Ubuntu

export RD_SHAREDDIR=/usr/share/rivendell


NOTE: If you reboot your computer or open a new terminal you will need to set these export variables again. You can avoid this by:

Add lines to .profile to set environmental variables on login (optional)

Use and editor and add the same lines from above to the bottom of your .profile it will be found in your home directory. In file managers you may need to select a menu option to see hidden files. If your linux user is rduser the to open it in gedit you could run

gedit /home/rduser/.profile

or using nano

nano /home/rduser/.profile

Then add lines similar to these. Adjust to match your setup.

export RD_LANGUAGES=/home/rduser/rdlanguages
export RD_SOURCE=/home/rduser/rivendell-1.7.2

and

export RD_SHAREDDIR=/usr/local/share/rivendell

or on Ubuntu

export RD_SHAREDDIR=/usr/share/rivendell

rdtrans.sh Usage

USAGE: rdtrans.sh <cmd> <lang>

Where <cmd> is one of the following:
'add', 'remove', 'update', 'read', 'write', 'test' or 'pack'

'add'    adds the needed lines to the .pro files in the source package.
'remove' removes the lines for the translation from the .pro files in the source package.
'update' updates or creates the .ts translation files in the source tree.
'read'   copies the translation files to your RD_LANGUAGES folder to be translated.
'write'  copies the translation files to the source tree from the RD_LANGUAGES folder it preparation for testing.
'test'   creates the .qm files and installs them in the Rivendell shared data directory for testing.
'pack'   makes an archive of the completed translations to send to the developer to be added to the source code.

Where <lang> is a i18n language code.
These are two letter codes for language. ie. German=de
These maybe followed by an underscore and a capitalize two letter country code.
ie. de_CH for German and Switzerland to create a country specific language code.
You can find a list in '''/usr/share/i18n/SUPPORTED''' on Ubuntu systems.
Run 'man locale' and check near the bottom of the man page for the location on your system of the SUPPORTED locale codes file.
Only the portion before .UTF-8 is needed.

Running rdtrans.sh

Before you run rdtrans.sh you need to figure out what your language code is. You can find a list in /usr/share/i18n/SUPPORTED on Ubuntu systems. Run man locale and check near the bottom of the man page for the location on your system of the SUPPORTED locale codes file.

Next run rdtrans.sh to create your translation files. The syntax looks like this:

rdtrans.sh <cmd> <lang>

Where <cmd> is add, remove, update, read, write, test, or pack and <lang> is a *.UTF-8 language code from the supported list. Only the part before the .UTF-8 is needed. In fact a general non-region specific file can also be made. So a non-region specific language file for German would be de while a German language file for Switzerland would be de_CH. To create a new set of files to translate for German for Switzerland you would run the following command:

./rdtrans.sh read de_CH

rdtrans.sh commands

Here is a basic guide to the <CMD> items:

Add

Adds the needed lines to the .pro files in the source package. This in effect adds the language to Rivendell. You should run this first and then later if new programs are added to Rivendell that you can translate for. An example of the line for German (de) for Switzerland (CH) would be:

TRANSLATIONS += rdairplay_de_CH
Remove

Removes the line from the .pro files in the source package. This is here in case you make a mistake an need to remove a language code.

Update

Updates or creates the .ts translation files in the source tree. You will need to run this to create the .ts files for each program. Later when new phrases or programs have been added to Rivendell you can run this again so that they will be added to your translation files (.ts). The translation files are named so: <name of the rivendell program>_<Language Code>.ts So for German for Switzerland (language code de_CH) for RDAirplay the language file would be named:

rdairplay_de_CH.ts
Read

Copies the translation files to your RD_LANGUAGES folder to be translated. You will need to run this each time after you run Update Language to get the translation files into your working folder.

Write

Copies the translation files to the source tree from the RD_LANGUAGES folder it preparation for testing. You will want to do this when you want to see what your translations look like in Rivendell or to pack them up and send them off to the developer for inclusion in the distributed source code.

This command along with the Test Language can also be used to install language files on currently installed systems.

Test

Creates the .qm files and installs them in the Rivendell shared data directory for testing. This makes the files need to run Rivendell with the translations you have created. It can also be used to install a language on a currently installed system with the write language command.

Pack

Makes an archive of the completed translations to send to the developer to be added to the source code. You will run this when you have completed your translation and it is ready to be included with Rivendell. Please email the archive that is created to the email address given in the dialog that pops up.

Setting up your translation files

For this tutorial we will use a translation of German for Switzerland. The language code for German is de, and the country code is CH. So, the language code for German for Switzerland is de_CH.

Open a terminal and go to the directory where you unpacked your Rivendell source code files. We are using /home/rduser/rivendell as our source code directory for this tutorial.

cd /home/rduser/rivendell/helpers

First add the language to the .pro files in the source code with:

./rdtrans.sh add de_CH

Then use update to create the .ts translation files in the source code tree.

./rdtrans.sh update de_CH

Then use read to copy the files to your working translations folder. To create a new set of files to translate for German for Switzerland you would run the following command:

./rdtrans.sh read de_CH

That should create a <lang> directory in the path specified by the environmental variable we set earlier called $RD_LANGUAGES. Inside that folder will be a set of files with names ending in '.ts' In our case we would look in /home/rduser/rdlanguages/de_CH for the .ts files.


Translating

For how to translate with Qt Linguist see this section of the Translations page.

Personal tools