use gettext

This commit is contained in:
Emmanuel Garette 2019-04-09 07:28:11 +02:00
parent 7130a53e7d
commit 0f38946670
2 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,4 @@
from .tiramisu_cmdline_parser import TiramisuCmdlineParser
from .api import TiramisuCmdlineParser
__version__ = "0.0.1"
__all__ = ('TiramisuCmdlineParser',)

View File

@ -15,6 +15,7 @@
from typing import Union, List, Optional
from argparse import ArgumentParser, Namespace, SUPPRESS, _HelpAction, HelpFormatter
from copy import copy
from gettext import gettext as _
try:
@ -139,13 +140,13 @@ class TiramisuCmdlineParser(ArgumentParser):
if args == ('-h', '--help'):
super().add_argument(*args, **kwargs)
else:
raise NotImplementedError('do not use add_argument')
raise NotImplementedError(_('do not use add_argument'))
def add_arguments(self, *args, **kwargs):
raise NotImplementedError('do not use add_argument')
raise NotImplementedError(_('do not use add_argument'))
def add_subparsers(self, *args, **kwargs):
raise NotImplementedError('do not use add_subparsers')
raise NotImplementedError(_('do not use add_subparsers'))
def _gen_argument(self, name, longargument, no_prefix=False):
shortarg = len(name) == 1 and not longargument
@ -186,7 +187,7 @@ class TiramisuCmdlineParser(ArgumentParser):
continue
name = option.name()
if name.startswith(self.prefix_chars):
raise ValueError('name cannot startswith "{}"'.format(self.prefix_chars))
raise ValueError(_('name cannot startswith "{}"').format(self.prefix_chars))
if self.fullpath and prefix:
name = prefix + '.' + name
properties = obj.property.get()
@ -206,7 +207,7 @@ class TiramisuCmdlineParser(ArgumentParser):
else:
if 'positional' in properties:
if option.type() == 'boolean':
raise ValueError('boolean option must not be positional')
raise ValueError(_('boolean option must not be positional'))
# if not 'mandatory' in properties:
# raise ValueError('"positional" argument must be "mandatory" too')
args = [option.path()]