import sys as _sys
import textwrap as _textwrap
-from gettext import gettext as _
+from gettext import gettext as _, ngettext
def _callable(obj):
conflict_handler(action, confl_optionals)
def _handle_conflict_error(self, action, conflicting_actions):
- message = _('conflicting option string(s): %s')
+ message = ngettext('conflicting option string: %s',
+ 'conflicting option strings: %s',
+ len(conflicting_actions))
conflict_string = ', '.join([option_string
for option_string, action
in conflicting_actions])
OPTIONAL: _('expected at most one argument'),
ONE_OR_MORE: _('expected at least one argument'),
}
- default = _('expected %s argument(s)') % action.nargs
+ default = ngettext('expected %s argument',
+ 'expected %s arguments',
+ action.nargs) % action.nargs
msg = nargs_errors.get(action.nargs, default)
raise ArgumentError(action, msg)
items = [
name
for name, value in vars(argparse).items()
- if not name.startswith("_")
+ if not (name.startswith("_") or name == 'ngettext')
if not inspect.ismodule(value)
]
self.assertEqual(sorted(items), sorted(argparse.__all__))