Language Translations
There is code in Control to be able to translate various words phrases.
While the translation does have some intelligence, it is somewhat limited. Eg. It is able to detect whether the original phrase is upper or lower case and adjust the translated text accordingly. However, it is not able to deal with mixed case text.
The translation tables have to be manually entered and compiled.
The Files
All translation files are stored in the $CCDIR/lang_ts folder. There are two types of files:
- .ts files - Human readable text file. The "source code"
- .qm files - Machine readable binary file. This is the file that the programs actually use.
Each set of translations will need to be placed in a separate set of .ts/.qm files. That is, Chinese translations are to be placed in files separate to the US English files. Also, the Sri Lankan English files are are to be separate from the US English files.
Using the Translations
To use the translation files,
Copy the appropriate .qm file into <CCDIR>/lang_ts/. Eg.
> cp my_translations.qm /u/cc/lang_ts/
- Set up page 2 of coaad so that the "Localisation settings" contains the name of the .qm file (without the .qm). This will set the translation globally.
my_translation
- Alternatively, if you only want it done for your terminal, you could set the CCLANG environment variable to the name of the .qm file. Do not use the directory name. Eg.
> export CCLANG=my_translations.qm
- Run Control.
Editing the Translation Table
To edit the translation table,
- Go to the lang_ts folder
> cd $CCDIR/lang_ts/
- Open the appropriate .ts file with a text editor. Eg:
> vi my_translations.ts
On the line immediately after the last </message> tag, insert
<message> <source>the_original_phrase</source> <translation>the_translated_phrase</translation> </message>The text inside the <source> tag MUST be lower case.
- Convert the .ts file into a .qm file
> $CCDIR/std/qtx11-3.3.5b/bin/lrelease my_translations.ts
- Test to ensure that it works
Note:
The translation translates both user interface items and printed items. It first tries to find an exact match. If it finds one, it is replaced with the replacement string. If it does not find one, it cuts it up to one of the allowed delimiters [ .,/?!] and tries to match the "words" between those delimiters. Because of the way everything is dynamically generated, and we only have a limited amount of screen/paper space, it is assumed that the translated phrase would be equal (preferred) or shorter than the original phrase. If the translated phrase is of a different length, certain printouts/displays (center, left justified, right justified) will not appear correctly. And if the translated phrase is longer than the original phrase, it could appear just fine, be in a strange position, or be overtyped by other adjacent strings.
