GRASS messages translation

From GRASS-Wiki
Revision as of 10:37, 10 February 2017 by Lucadelu (talk | contribs) (improved transifex doc)
Jump to navigation Jump to search

Help page translations

GRASS messages translation project

Many users prefer to use software in their mother tongue which is mostly not English. This requires that all GRASS software messages have to be translated to languages other than English. The GRASS Development Team is seeking translators. Please subscribe to the dedicated mailing list at

    GRASS translations mailing list
    http://lists.osgeo.org/mailman/listinfo/grass-translations

Translation related issues may be discussed there. This is an opportunity for non-programmers to contribute as messages can be easily translated. No programming skills required!

Wanted languages

Simple Chinese, Swahili, Hindi, Greek, Tamil, Russian, Telugu, Português, ... Please join us!

How to change the language

How to start or update translations

Files to be edited (downloaded)

GRASS GIS 6

In GRASS GIS 6, we have 5 types of .po files per language (the files are stored in the source code, in directory locale/po/;
or simply download .po files here):

  • grasslibs_LANG.po: messages from libraries
  • grassmods_LANG.po: messages from commands ("modules")
  • grassnviz_LANG.po: messages from NVIZ Tcl/Tk graphical user interface (GRASS 6)
  • grasstcl_LANG.po: messages from Tcl/Tk graphical user interface (GRASS 6)
  • grasswxpy_LANG.po: messages from wxgrass/wxPython graphical user interface

where "LANG" in the above file names is a two character code which indicates the language. It is based on the Alpha-2 code of ISO 639-1 (right column). Example: grasswxpy_pl.po for Polish.

GRASS GIS 7

In GRASS GIS 7, we have only 3 types of .po files per language (the files are stored in the source code, in directory locale/po/;
or simply download .po files here):

  • grasslibs_LANG.po: messages from libraries
  • grassmods_LANG.po: messages from commands ("modules")
  • grasswxpy_LANG.po: messages from wxgrass/wxPython graphical user interface

where "LANG" in the above file names is a two character code which indicates the language. It is based on the Alpha-2 code of ISO 639-1 (right column). Example: grasswxpy_pl.po for Polish.

Continuing an existing translation

The file(s) are there but partially outdated? Read on.

First announce on the GRASS translations mailing list that you plan to continue the translation of a certain language. Why? Because sometimes people silently translate already and we need these efforts to be coordinated to avoid doing it twice...

Then get these four .po files for your language and start. If a file is missing, just ask on the list to get it generated or see next section. To get these .po files (the files are in the directory locale/po/):

Then edit the files with a .po file editor (poEDIT or kbabel or..., see below). Take care to maintain layout and special characters. And submit often - if you wait for weeks, the messages may already be outdated and your time wasted. Just keep in touch on the GRASS translations mailing list!

Starting a new translation

The language you want isn't yet there? Read on.

Briefly, the steps to create new messages files are (if you find this too complicated, ask on the GRASS translations mailing list to get these files done for you!):

  1. Get the latest source code development version from either the SVN repository or as SVN snapshot (see Download).
  2. run: './configure --with-nls [... other parameters]' to configure the GRASS source code
  3. run: 'cd locale' to change into the translation directory
  4. run: 'make pot' to create grass*.pot template files (to extract original messages)
  5. run: copy these file from templates/ into po/; rename them to contain the two characters language code (see Alpha-2 code of ISO 639-1) and to .po extension; update the file headers either manually or with your .po editing software
 (Example: Polish language):
	        mv ./templates/grasslibs.pot ./po/grasslibs_pl.po
	        mv ./templates/grassmods.pot ./po/grassmods_pl.po
	        mv ./templates/grassnviz.pot ./po/grassnviz_pl.po
	        mv ./templates/grasstcl.pot ./po/grasstcl_pl.po
	        mv ./templates/grasswxpy.pot ./po/grasswxpy_pl.po

Now translate the messages in these po/*.po files (using poEDIT or other editor, see below)

From time to time messages need to be updated from the originals. This is usually done by the GRASS translation manager.

Software to translate: .po file editors

Transifex

Create a new project

NOTE: CORE DEVELOPERS ONLY!

A project should be done for each stable release, only an Organization Administrators can create a project. From the dashboard in the left bottom corner there is "New project" button. Fill all the field in the form. More info in Transifex documentation

Once the new project is created you need to upload the resources (the pot file to translate). To create the pot files you can execute

 make pot

inside the locale folder. Now you can load in the Resource section, after you added them you can link the pot file with an online version to get updates. To do this click on "Auto update resources" bottom (read also the Transifex documentation.

At this point you need to load the translated po files, for each language and file you have to upload the translation po file. Some errors could appear, resolution of this problems is a TODO

Get the translated po files

NOTE: THIS IS FOR DEVELOPER OR POWER USER

It is possible to get back the translated po files automatically using the Transifex client

To download the file it is required to create a folder to initialize the Transifex project using the command

tx init --user=USERNAME --passwd=PASSWORD

--user and --passwd option are useful to create the .transifexrc file in your $HOME to save user and password, otherwise you can create the file by your self, like the following one

[1]
hostname = https://www.transifex.com
password = PASSWORD
token = 
username = USERNAME

At this point you need to configure the repository modifying the .tx/config file created in your folder. The following file is working for GRASS 7.2 project, you need to add a section for each resource.

[main]
host = https://www.transifex.com

[grass72.grasslibspot]
type = PO
source_lang = en
source_file = ../templates/grasslibs.pot

[grass72.grassmodspot]
type = PO
source_lang = en
source_file = ../templates/grassmods.pot

[grass72.grasswxpypot]
type = PO
source_lang = en
source_file = ../templates/grasswxpy.pot

NOTE: THIS SHOULD NOT BE RUN IF YOU WANT TO RUN transifex_merge.sh

Now you can download all the translated po files with the following command

tx pull -a

Testing different languages

Testing different languages requires that the respective language environment and, if needed, fonts are installed. Check what languages are currently installed on your system with:

 locale -a

To change to a certain language environment (locale), do the following steps (here, example for Unix style environment):

  1. Define/check language settings:
    echo $LANG
    echo $LANGUAGE
    echo $LC_MESSAGES
 
  2. Change it (example for to Japanese):
   a) bash shell:
        export LANG=ja_JP.UTF-8
        export LANGUAGE=ja_JP.UTF-8
        export LC_MESSAGES=ja_JP.UTF-8
 
 
   b) (t)csh shell:
        setenv LANG ja_JP.UTF-8
        setenv LANGUAGE ja_JP.UTF-8
        setenv LC_MESSAGES ja_JP.UTF-8

Now launch GRASS in this terminal. If you launch it from an icon, you have to change the LOCALE in the computer setup program instead.

Other common languages useful for testing are de_DE for German, fr_FR for French, or "C" for none (effectively en_US, which for GRASS is the base language).

Creating startup scripts for different languages

GRASS in English language, save as "grass64eng" (executable flag set, store in path):

     #!/bin/sh
     export LANG=en_US
     export LANGUAGE=en_US
     export LC_MESSAGES=en_US
     exec grass64 "$@"

GRASS in Japanese language, save as "grass64ja" (executable flag set, store in path):

     #!/bin/sh
     export LANG=ja_JA.UTF-8
     export LANGUAGE=ja_JA.UTF-8
     export LC_MESSAGES=ja_JA.UTF-8
     grass64 "$@"

Coordination among translators

If several translators work on the same language files, obviously some coordination is needed. Please announce work via the "translations" mailing list at http://lists.osgeo.org/mailman/listinfo/grass-translations

Also the translation manager is listening there to the upload the changed files into the GRASS source code repository.

Best practices

Installation of language packages

Example: Chinese

  • Mandriva: urpmi locales-zh kde-l10n-zh_CN fonts-ttf-default-zh_CN
  • Fedora: the locales should be already present
    • list all valid locales on the system: localectl list-locales
    • show current settings: localectl status
    • set new locale: localectl set-locale LANG=zh_CN.utf8 LC_MESSAGES=zh_CN.utf8

Updating messages in the source code

Generally, to support i18N multiple languages, message strings in GRASS must be modified by adding so-called gettext macros _("...").

C programming language

Change from

 fprintf ( ..., "...\n", ...);

to either

 fprintf ( ..., _("...\n"), ...);

or usually (while omitting \n)

 G_message ( _("..."), ...);

Python programming language

In Python, the macro is used like this:

grass.message(_('Raster map <{name}> unpacked'.format(name=map_name)))

Important hints

Beware:

  • G_message should be used for messages - information about the process for user while fprintf(stdout...) for data output.
  • G_message output is not expected to be send to pipe or file.
  • fprintf(stdout...) output is usually send to pipe or file.

Programming details are available in the file locale/README.

Important:

See also