Translate your application
Prev Glade2script Reference Manual Next

Translate your application

xgettext, msginit et msgfmt must be installed first. ( Already installed by default in Ubuntu ).
You will need a locale folder placed in the script/glade repository. Subfolders indicating the language choice (fr, en, es, ...) and another sub-folder called LC_MESSAGES must be created for each language.
If you want to use another converntion for 'locale' traduction, you should fill the --locale option.

At the very beginning of the associated script *

#! /bin/bash
path="$(cd "$(dirname "$0")";pwd)"
###Used to export the gettext library
set -a
set +a
export TEXTDOMAIN=Test    # here the name of the  .mo, .glade, ....
export TEXTDOMAINDIR="${chemin}/locale"
# Text to be translated in the script
$(eval_gettext "texte to translate")
Using a glade2script command
echo "SET@_label1.set_text('$(eval_gettext "texte to translate")')"

Creating the language files

A .dot file should firstly be created. This file will be used as a basis for creating the .po file. The .po and .mo (.dot) should have the same name as the glade file.
cd ./dirscript
xgettext -o Test.pot
#or xgettext -o Test.pot *.glade *.sh
msginit -i Test.pot -o Test.po
The traduction should be placed in the .po file.

Then :
msgfmt Test.po -o
The .mo file will be used to translate the interface and the script. It should be pasted in the LC_MESSAGES repository of the corresponding language.

* pasted on a frafa script coming from the french forum ubuntu

Prev Glade2script Reference Manual Next