From: Serge Rehbinder Date: Wed, 27 Jan 2016 08:42:03 +0000 (+0100) Subject: internationalization : fr traduction X-Git-Tag: sprint-01~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5e9fab0f9e8e587c1190662e617cffdcedf59e9c;p=tools%2Fsat.git internationalization : fr traduction --- diff --git a/src/common/architecture.py b/src/common/architecture.py index 241e50f..8a9b417 100644 --- a/src/common/architecture.py +++ b/src/common/architecture.py @@ -59,8 +59,8 @@ def _lsb_release(args): res = res.decode() return res except OSError: - sys.stderr.write(_("lsb_release not installed\n")) - sys.stderr.write(_("You can define $LSB_PATH to give the path to lsb_release\n")) + sys.stderr.write(_(u"lsb_release not installed\n")) + sys.stderr.write(_(u"You can define $LSB_PATH to give the path to lsb_release\n")) sys.exit(-1) def get_distribution(codes): @@ -77,8 +77,8 @@ def get_distribution(codes): if codes is not None and distrib in codes: distrib = codes[distrib] else: - sys.stderr.write(_("Unknown distribution: '%s'\n") % distrib) - sys.stderr.write(_("Please add your distribution to data/distrib.pyconf\n")) + sys.stderr.write(_(u"Unknown distribution: '%s'\n") % distrib) + sys.stderr.write(_(u"Please add your distribution to data/distrib.pyconf\n")) sys.exit(-1) return distrib @@ -116,7 +116,7 @@ def get_nb_bit(): elif nb_bit == "32bit": nb_bit = "32" else: - sys.stderr.write(_("Unknown architecture: '%s'\n") % nb_bit) + sys.stderr.write(_(u"Unknown architecture: '%s'\n") % nb_bit) sys.exit(-1) return nb_bit diff --git a/src/common/i18n/build_strings.sh b/src/common/i18n/build_strings.sh new file mode 100755 index 0000000..9e2a95f --- /dev/null +++ b/src/common/i18n/build_strings.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# This script gets the strings to internationalise from the source code + +I18HOME=`dirname $0` +SRC_DIR=$I18HOME/../.. + +# get strings for french translation +echo Build strings for French + +poFile=$I18HOME/fr/LC_MESSAGES/salomeTools.po +refFile=$I18HOME/fr/LC_MESSAGES/ref.pot + +xgettext $SRC_DIR/*.py $SRC_DIR/common/*.py \ + --no-wrap --no-location --language=Python --omit-header \ + --output=$refFile +msgmerge -q --update $poFile $refFile +msgattrib --no-obsolete -o $poFile $poFile +rm $refFile + diff --git a/src/common/i18n/fr/LC_MESSAGES/salomeTools.mo b/src/common/i18n/fr/LC_MESSAGES/salomeTools.mo new file mode 100644 index 0000000..a63767d Binary files /dev/null and b/src/common/i18n/fr/LC_MESSAGES/salomeTools.mo differ diff --git a/src/common/i18n/fr/LC_MESSAGES/salomeTools.po b/src/common/i18n/fr/LC_MESSAGES/salomeTools.po new file mode 100644 index 0000000..594e6c8 --- /dev/null +++ b/src/common/i18n/fr/LC_MESSAGES/salomeTools.po @@ -0,0 +1,41 @@ +msgid "shows global help or help on a specific command." +msgstr "affiche l'aide gnrale ou pour une commande spcifique." + +msgid " is not a valid command" +msgstr " n'est pas une commande valide" + +msgid "Usage: " +msgstr "Utilisation : " + +msgid "Available commands are:\n" +msgstr "Les commandes disponibles sont:\n" + +msgid "" +"\n" +"Getting the help for a specific command: " +msgstr "" +"\n" +"Obtenir l'aide d'une commande spcifique : " + +msgid "lsb_release not installed\n" +msgstr "lsb_release n'est pas install\n" + +msgid "You can define $LSB_PATH to give the path to lsb_release\n" +msgstr "Vous pouvez dfinir $LSB_PATH pour donner le chemin vers lsb_release\n" + +#, python-format +msgid "Unknown distribution: '%s'\n" +msgstr "Distribution inconnue : '%s'\n" + +msgid "Please add your distribution to data/distrib.pyconf\n" +msgstr "SVP ajoutez votre distribution au fichier data/distrib.pyconf\n" + +#, python-format +msgid "Unknown architecture: '%s'\n" +msgstr "Architecture inconnue: '%s'\n" + +msgid " is not a valid option" +msgstr " n'est pas une option valide" + +msgid "Available options are:" +msgstr "Les options disponibles sont:" diff --git a/src/common/i18n/translate.py b/src/common/i18n/translate.py new file mode 100644 index 0000000..a7a8171 --- /dev/null +++ b/src/common/i18n/translate.py @@ -0,0 +1,4 @@ +#/bin/env python +import polib +po = polib.pofile('fr/LC_MESSAGES/salomeTools.po', encoding='utf-8') +po.save_as_mofile('fr/LC_MESSAGES/salomeTools.mo') diff --git a/src/common/i18n/translate.sh b/src/common/i18n/translate.sh new file mode 100755 index 0000000..5ad2b2c --- /dev/null +++ b/src/common/i18n/translate.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# this script creates the binary resources file from the strings file + +I18HOME=`dirname $0` + +# french +echo build French ressources +msgfmt ${I18HOME}/fr/LC_MESSAGES/salomeTools.po -o ${I18HOME}/fr/LC_MESSAGES/salomeTools.mo + diff --git a/src/common/options.py b/src/common/options.py index 4a0f59d..e3c5545 100644 --- a/src/common/options.py +++ b/src/common/options.py @@ -42,7 +42,7 @@ class OptResult(object): if name in self.__dict__: return self.__dict__[name] else: - raise AttributeError(name + " is not a valid option") + raise AttributeError(name + _(u" is not a valid option")) def __setattr__(self, name, value): '''Overwrite of the __setattr__ function to customize it for option usage @@ -98,7 +98,7 @@ class Options: return # for all options, print its values. "shortname" is an optional field of the options - print(printcolors.printcHeader("Available options are:")) + print(printcolors.printcHeader(_("Available options are:"))) for option in self.options: if 'shortName' in option and len(option['shortName']) > 0: print(" -%(shortName)1s, --%(longName)s (%(optionType)s)\n\t%(helpString)s\n" % option) diff --git a/src/salomeTools.py b/src/salomeTools.py index bbfa571..3eaab74 100755 --- a/src/salomeTools.py +++ b/src/salomeTools.py @@ -23,24 +23,20 @@ import os import sys import imp import types +import gettext + import common.options import config -def copy_func(f, name=None): - ''' - return a function with same code, globals, defaults, closure, and - name (or provide a new name) - ''' - - fn = types.FunctionType(f.__code__, f.__globals__, name or f.__name__, - f.__defaults__, f.__closure__) - # in case f was given attrs (note this dict is a shallow copy): - fn.__dict__.update(f.__dict__) - return fn - # get path to salomeTools sources srcdir = os.path.dirname(os.path.realpath(__file__)) +# load resources for internationalization +#gettext.install('salomeTools', os.path.join(srcdir, 'common', 'i18n')) + +es = gettext.translation('salomeTools', os.path.join(srcdir, 'common', 'i18n')) +es.install() + def find_command_list(): cmd_list = [] for item in os.listdir(srcdir): @@ -54,7 +50,7 @@ lCommand = find_command_list() # Define all possible option for salomeTools command : sat