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):
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
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
--- /dev/null
+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:"
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
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)
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):
# Define all possible option for salomeTools command : sat <option> <args>
parser = common.options.Options()
-parser.add_option('h', 'help', 'boolean', 'help', "shows global help or help on a specific command.")
+parser.add_option('h', 'help', 'boolean', 'help', _(u"shows global help or help on a specific command."))
class salomeTools(object):
def __init__(self, options, dataDir=None):
if name in self.__dict__:
return self.__dict__[name]
else:
- raise AttributeError(name + " is not a valid command")
+ raise AttributeError(name + _(" is not a valid command"))
def __setattr__(self, name, value):
object.__setattr__(self,name,value)
for nameCmd in lCommand:
(file_, pathname, description) = imp.find_module(nameCmd, [dirPath])
module = imp.load_module(nameCmd, file_, pathname, description)
-
+
def run_command(args):
print('Je suis dans l\'initialisation de la commande ' + __name__)
argv = args.split(" ")
globals_up = {}
globals_up.update(run_command.__globals__)
globals_up.update({'__name__': nameCmd, '__module__' : module})
- fn = types.FunctionType(run_command.__code__, globals_up, run_command.__name__,run_command.__defaults__, run_command.__closure__)
+ func = types.FunctionType(run_command.__code__, globals_up, run_command.__name__,run_command.__defaults__, run_command.__closure__)
- self.__setattr__(nameCmd, fn)
+ self.__setattr__(nameCmd, func)
#print_version(cfg)
#print
- print(common.printcolors.printcHeader( "Usage: " ) + "sat [sat_options] <command> [product] [command_options]\n")
+ print(common.printcolors.printcHeader( _("Usage: ") ) + "sat [sat_options] <command> [product] [command_options]\n")
parser.print_help()
# parse the src directory to list the available commands.
- print(common.printcolors.printcHeader("Available commands are:\n"))
+ print(common.printcolors.printcHeader(_("Available commands are:\n")))
for command in lCommand:
print(" - %s" % (command))
- print(common.printcolors.printcHeader("\nGetting the help for a specific command: " + "sat --help <command>\n"))
+ print(common.printcolors.printcHeader(_(u"\nGetting the help for a specific command: ")) + "sat --help <command>\n")
def write_exception(exc):
sys.stderr.write("\n***** ")