From 5e9fab0f9e8e587c1190662e617cffdcedf59e9c Mon Sep 17 00:00:00 2001 From: Serge Rehbinder Date: Wed, 27 Jan 2016 09:42:03 +0100 Subject: [PATCH] internationalization : fr traduction --- src/common/architecture.py | 10 ++--- src/common/i18n/build_strings.sh | 20 +++++++++ src/common/i18n/fr/LC_MESSAGES/salomeTools.mo | Bin 0 -> 1135 bytes src/common/i18n/fr/LC_MESSAGES/salomeTools.po | 41 ++++++++++++++++++ src/common/i18n/translate.py | 4 ++ src/common/i18n/translate.sh | 10 +++++ src/common/options.py | 4 +- src/salomeTools.py | 36 +++++++-------- 8 files changed, 98 insertions(+), 27 deletions(-) create mode 100755 src/common/i18n/build_strings.sh create mode 100644 src/common/i18n/fr/LC_MESSAGES/salomeTools.mo create mode 100644 src/common/i18n/fr/LC_MESSAGES/salomeTools.po create mode 100644 src/common/i18n/translate.py create mode 100755 src/common/i18n/translate.sh 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 0000000000000000000000000000000000000000..a63767dbf1ced56e53490a5c5bf0549e86a551d6 GIT binary patch literal 1135 zcmaKq%W4!s6oyNUxAp>NVI#0PQj!ky?VxOd}UJ>8v-BQ_kqu5*f0r~bcwEH8Z!_%0%DAl@RbAig8+A?Sn< zE8uhRDj0*;z{7g|9(;)PXYe}sv*vH`EY>S0g;)n~gR9^UxCVOgKKK#51%3s?`M*E{ zFP#$NCfElbgF`UX-_`j~;AO18fSceqF!Whn65r$ zBwm@<#_k(*j#K41_63fh-d)!_s&yN+H7BRoD0XZ?u{4zML>Z<#!>uQ~qruB(;lQaX zxsoN5J`D-&#=ALJV@9I0s8mtLd8sugk#MQqcQn;@EcIMdNLp!&n=DG(7txEcXQOh` zJ*g6=q*q{=T6u;S!HPEpQ*gob*m=sNqhp&YPx$ZhT;aK4EQajbt}Y0iS)<^PBWI0= zHDN 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