# Translations module

## Introduction

The translations module contains all the avaliable translations for strings in the Opera core, and most of the user interfaces. This module works in tandem with the strings module. Please see the strings module documentation for implementation details.

For further information, please refer to the wiki page.

Current volunteer translator languages.

### Translation files

Translation uses the standard `PO` file format for translations. Refer to the gettext manual for more information on the format.

Note: names of languages are specified by RFC 4646, which defines a general form based on ISO 639-1 (2-letter language codes), ISO 639-2 (3-letter language codes) and ISO 3166 (country codes); it augments this with a list of extensions maintained by IANA (including several tags from the previous RFC edition which are now covered by the current edition). The ISO 639 language codes are tabulated at The library of congress and RFC 4646 mandates the use of two-letter codes where they are defined, in preference to three-letter ones.

### Other files

For certain languages and platforms, other files can be available in the language subdirectories. Contact the module owner for further details on these files.

## Translating

Create and update the PO file using the scripts described below. Translate the PO file. New translations start out with the `opera.pot` file, renaming it to `language.po`.

The form of the entries in this file is:

     #. Scope: m2
     #: D_M2_ACCOUNT_PROPERTIES_GENERAL:67000
     msgctxt "D_M2_ACCOUNT_PROPERTIES_GENERAL"
     msgid "General"
     msgstr ""

The translator edits the file, adding the translation:

     #. Scope: m2
     #: D_M2_ACCOUNT_PROPERTIES_GENERAL:67000
     msgctxt "D_M2_ACCOUNT_PROPERTIES_GENERAL"
     msgid "General"
     msgstr "Allmänt"

The translator can add their own comments (which will be retained when updating):

     # Not the military rank
     #. Scope: m2
     #: D_M2_ACCOUNT_PROPERTIES_GENERAL:67000
     msgctxt "D_M2_ACCOUNT_PROPERTIES_GENERAL"
     msgid "General"
     msgstr "Allmänt"

This `PO` file will contain all strings (but see note on the makepot.pl script).

Create a release LNG file using the makelang.pl script from the strings module, as described below.

Translators can use the lngtest program to create `LNG` files during translation testing.

## Utility scripts for translations

There are a number of scripts available in the top-level directory of the module.

The translations module provides the following scripts. To see a full list of command line parameters for each script, please pass a command line of `-?` or `--help`.

The scripts are written in Perl. On some platforms, you may need to explicitly state this when running the script from the command line, by starting the command line with the word `perl`.

### `makelang.pl`

Note: This script is located in the strings module, but is also used to generate translated language files, using the `PO` files provided by this module.

Makelang is used to create the language files that are delivered with the Opera builds, both the English file that is created by using the auto-generated `en.po` "localization", and the translated versions using the `PO` files delivered by the translators and stored in this module.

To create a `LNG` file, make sure you have a version of the strings module matching this one. Run `makelang.pl` with the `-t` option specifying the location of the translated `PO` file. Use the `data/translations/en/en.po` file (`-t en`) to create an English language file.

Use the `-b` parameter to specify the path to the `build.strings` file for your build. This file contains a generated list of strings relevant for your build, and must be specified to generate a language file.

You also need to specify the `-p` parameter to define the target build data. The build number defined by the `-p` parameter is made available at run-time to check that the language file is for a current version of Opera.

Any missing strings for the translation will be flagged as errors, to give the translator the opportunity to update that string. If you get a warning about missing strings when generating an English language file (using `-t en`), this can be for several reasons:

- The version of your strings module does not match that of the translations module.
- You have local modifications to the `english.db` file in the strings module that have not been applied upstream.
- Your build is using a string flagged with the "internal" scope. These strings are not available for translation. If you need one of these strings, you need to file a patch to update `english.db`.

#### Example uses

All example commands described here should be given on one line.

`../strings/scripts/makelang.pl -t sv -p Win,9.00,8501 -b windows/8501/build.strings`

To use a specific version of the language database file, use the `-r` parameter:

`../strings/scripts/makelang.pl -r chicago_db837 -t sv -p Win,9.00,8501 -b windows/8501/build.strings`

To use a specific version of the translated PO file, use the `-R` parameter:

`../strings/scripts/makelang.pl -r chicago_db837 -R babel_1_db837 -t sv -p Win,9.00,8501 -b windows/8501/build.strings`

The `-o` parameter can be used to control where the output file is created:

`../strings/scripts/makelang.pl -t sv -o sv/sv.lng -p Win,9.00,8501 -b windows/8501/build.strings`

If the `.po` file does not have the same name as the directory it is placed in, you will have to specify the full file after the `-t` parameter:

`../strings/scripts/makelang.pl -t id/id_symbian.po -p Win,9.00,8501 -b windows/8501/build.strings`

It is also possible to specify a second PO file to override entries from the first one, using the `-T` parameter. This is used to handle platforms where some strings are translated differently:

`../strings/scripts/makelang.pl -t en -T en/mac.po -p Mac,9.00,3447 -b mac/3447/build.strings`

Other translation file formats can also be generated, and there are several option to tailor the files output (for instance converting the ellipsis character, “…”, to three full stops, “...”, or removing menu shortcut keys from the generated files).

Please see the help screen for full details:

`../strings/scripts/makelang.pl -?`

### `makeall.pl`

This is a utility script that makes it easier to generate all the translation files for a given build on a given platform. It will locate all the translation files available, and generates the appropriate language files.

Run the script without any command-line parameters for a summary on how to use it.

### `join.pl`

This script is used to join two partial translations for the same language into one `PO` file. The script takes three parameters, the two `PO` files to join and a `PO`file to create with the resulting data.

If there are any conflicts, i.e different translations, the translation file that was specified first on the command line takes precedence. The translated string from the second file will be added in a comment and the string Translation conflict: will be added.

Any empty and fuzzy strings are discarded.

The order of strings is not kept.

### `makepot.pl`

This script writes a translation template to the file `en/opera.pot` based on the currently checked out version of the string database (`english.db`). This file, `en/opera.pot`, is used as the template for new translation, and the basis for updates of the translated PO files. It is not checked in to GIT.

Make sure you have the proper version of `english.db` checked out from the strings before using this script, you would not normally do this for the "bleeding edge" version of the database.

You can specify a specific revision (or release tag) of the string database by using the `-r` parameter:

`makepot.pl -r chicago_db839`

`makepot.pl -r o76_core1build_3333`

`makepot.pl -r 1.228`

When translating only a single version, you can include strings specific to that build by using the `-b` parameter:

`makepot.pl -b build.strings`

This can also be used to create a template for any subset, for instance for a Mac-specific translation:

`makepot.pl -b en/mac.strings`

For translators that only translate the desktop version, you can exclude non-desktop strings from the opera.pot by specifying the `-d` parameter:

`makepot.pl -d`

The list of scopes that are excluded when this parameter is given is defined at the top of the `makepot.pl` script, and need to be updated when new embedded systems are added.

There are more command line parameters for this script, please see the help screen for more details.

Note: This script is just a wrapper around `makelang.pl` from the strings module (see also above). You need both the source trees checked out to use this script.

### `merge.pl`

This script is used to merge a current translation with a new template file (generated by `makepot.pl`). You must have `msgmerge` (from GNU gettext) installed to run this script. First make sure that the template file (`en/opera.pot`) for the required version is available, and that the translated `.po` file is available, then run the `merge.pl` script like this:

`merge.pl sv`

If the `.po` file does not have the same name as the directory it is placed in, you will have to specify the full file name:

`merge.pl id/id_symbian.po`

This will update and rewrite the specified `PO` file.

If you run `merge.pl` without parameters, an interactive dialog will be initiated.

Advanced: You can also run msgmerge directly (for instance: `msgmerge -o sv/new.po sv/sv.po en/opera.pot`), but this requires you to manually move the new file over. Also, the database version number reference in the file header is not updated. Read the gettext manual for further information.

### `migrate.pl`

This script is used to migrate old language files from before version 7 to the current `PO` format. It will read the `LNG` file specified either on the command line or in the interactive dialogue and create a new file with the same base name and path as the `LNG` file but with the extension `.po`. This file can then be updated with the current English strings as described above.

It can also be used to convert `LNG`-only translations to the `PO` format. To achieve this, the matching English `LNG` file is required.

### `lngjoin.pl`

This script is used to create common language files for different platforms. To use the script, you first generate the language files you want to join using the standard `makelang.pl` script as usual, and then run `lngjoin.pl` on these files to create a merged language file. The files you want to join must all be based on the same language database.

To use these joined files, `FEATURE_EXTENDED_LANGUAGE_FILE` must be enabled in the build.

### `fixmsgids.pl`

This script is used to check msgids (containing English strings) in files for given language. To use the script run it with name of language directory as a parameter. It will check normal `PO` file in this directory, a Chameleon `PO` file and compare the msgids with English strings in `english.db`. In case when Opera `PO` file contains string matching `english.db` entry, and Chameleon `PO` file doesn't, script (if run with `-g` parameter) will correct the second one (if additionally `-i` parameter is given, file will be changed in-place, otherwise files with `-new` suffix will be generated). Script displays information about other errors encountered, which couldn't be fixed automatically.

### `fixmsgids.sh`

This script automates usage of `fixmsgids.pl`, runs this script for each directory containing Chameleon `PO` files, saving information about errors to be corrected manually and about modified strings into `fixmsgids.log`. If `-i` parameter is given, it will be added to each invocation of `fixmsgids.pl`.

## Other translator utilities

### `lngtest` (Opera utility)

This program creates a simple LNG file suitable for testing, containing all the strings in the PO file submitted on the command line.

### `kbabel` (part of KDE)

Kbabel is a GUI program for KDE that allows easy editing of PO files, and it can be used if editing the .po files directly feels to cumbersome.

### `gtranslator` (part of Gnome)

Gtranslator is similar to kbabel, but uses the Gnome UI.

## References

- Strings module
- Locale module