~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commands.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-16 13:27:14 UTC
  • mfrom: (6138.3.15 i18n-gettext-errors)
  • Revision ID: pqm@pqm.ubuntu.com-20110916132714-w81xvesg996w68r6
(jr) Add gettext() to user error messages
 (Jonathan Riddell)

Show diffs side-by-side

added added

removed removed

Lines of Context:
229
229
    try:
230
230
        return _get_cmd_object(cmd_name, plugins_override)
231
231
    except KeyError:
232
 
        raise errors.BzrCommandError('unknown command "%s"' % cmd_name)
 
232
        raise errors.BzrCommandError(gettext('unknown command "%s"') % cmd_name)
233
233
 
234
234
 
235
235
def _get_cmd_object(cmd_name, plugins_override=True, check_missing=True):
815
815
    try:
816
816
        options, args = parser.parse_args(args)
817
817
    except UnicodeEncodeError,e:
818
 
        raise errors.BzrCommandError('Only ASCII permitted in option names')
 
818
        raise errors.BzrCommandError(gettext('Only ASCII permitted in option names'))
819
819
 
820
820
    opts = dict([(k, v) for k, v in options.__dict__.iteritems() if
821
821
                 v is not option.OptionParser.DEFAULT_VALUE])
839
839
                argdict[argname + '_list'] = None
840
840
        elif ap[-1] == '+':
841
841
            if not args:
842
 
                raise errors.BzrCommandError("command %r needs one or more %s"
843
 
                                             % (cmd, argname.upper()))
 
842
                raise errors.BzrCommandError(gettext(
 
843
                      "command {0!r} needs one or more {1}").format(
 
844
                      cmd, argname.upper()))
844
845
            else:
845
846
                argdict[argname + '_list'] = args[:]
846
847
                args = []
847
848
        elif ap[-1] == '$': # all but one
848
849
            if len(args) < 2:
849
 
                raise errors.BzrCommandError("command %r needs one or more %s"
850
 
                                             % (cmd, argname.upper()))
 
850
                raise errors.BzrCommandError(
 
851
                      gettext("command {0!r} needs one or more {1}").format(
 
852
                                             cmd, argname.upper()))
851
853
            argdict[argname + '_list'] = args[:-1]
852
854
            args[:-1] = []
853
855
        else:
854
856
            # just a plain arg
855
857
            argname = ap
856
858
            if not args:
857
 
                raise errors.BzrCommandError("command %r requires argument %s"
858
 
                               % (cmd, argname.upper()))
 
859
                raise errors.BzrCommandError(
 
860
                     gettext("command {0!r} requires argument {1}").format(
 
861
                               cmd, argname.upper()))
859
862
            else:
860
863
                argdict[argname] = args.pop(0)
861
864
 
862
865
    if args:
863
 
        raise errors.BzrCommandError("extra argument to command %s: %s"
864
 
                                     % (cmd, args[0]))
 
866
        raise errors.BzrCommandError( gettext(
 
867
                              "extra argument to command {0}: {1}").format(
 
868
                                       cmd, args[0]) )
865
869
 
866
870
    return argdict
867
871