mark more messages for translation
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parent 03e2fee · Browse files · 15 files·+218 added−117 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
15 files+218 added−117 removed
- tests:+6 added−6 removed
- other:+212 added−111 removed
Provenance
- Commit
8d49e14- Tree
145b7c3- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
03e2fee
15 files changed+218 added−117 removed
modified:src/click/_termui_impl.py+7 added-2 removed
6 unmodified lines7 import math8 import os9 import sys10 import time11+from gettext import gettext as _12 13 from ._compat import _default_text_stdout14 from ._compat import CYGWIN15 from ._compat import get_best_encoding473 unmodified lines489 try:490 c = subprocess.Popen(f'{editor} "{filename}"', env=environ, shell=True)491 exit_code = c.wait()492 if exit_code != 0:492- raise ClickException(f"{editor}: Editing failed!")493+ raise ClickException(494+ _("{editor}: Editing failed").format(editor=editor)495+ )496 except OSError as e:494- raise ClickException(f"{editor}: Editing failed: {e}")497+ raise ClickException(498+ _("{editor}: Editing failed: {e}").format(editor=editor, e=e)499+ )500 501 def edit(self, text):502 import tempfile503 197 unmodified linesmodified:src/click/_unicodefun.py+39 added-28 removed
1 import codecs2 import os3+from gettext import gettext as _4 5 6 def _verify_python_env():7 """Ensures that the environment is good for Unicode."""5 unmodified lines13 fs_enc = "ascii"14 if fs_enc != "ascii":15 return16 16- extra = ""17+ extra = [18+ _(19+ "Click will abort further execution because Python was"20+ " configured to use ASCII as encoding for the environment."21+ " Consult https://click.palletsprojects.com/unicode-support/"22+ " for mitigation steps."23+ )24+ ]25+26 if os.name == "posix":27 import subprocess28 29 try:15 unmodified lines45 good_locales.add(locale)46 if locale.lower() in ("c.utf8", "c.utf-8"):47 has_c_utf8 = True48 40- extra += "\n\n"49 if not good_locales:50+ extra.append(42- extra += (43- "Additional information: on this system no suitable"44- " UTF-8 locales were discovered. This most likely"45- " requires resolving by reconfiguring the locale"46- " system."51+ _(52+ "Additional information: on this system no suitable"53+ " UTF-8 locales were discovered. This most likely"54+ " requires resolving by reconfiguring the locale"55+ " system."56+ )57 )58 elif has_c_utf8:49- extra += (50- "This system supports the C.UTF-8 locale which is"51- " recommended. You might be able to resolve your issue"52- " by exporting the following environment variables:\n\n"53- " export LC_ALL=C.UTF-8\n"54- " export LANG=C.UTF-8"59+ extra.append(60+ _(61+ "This system supports the C.UTF-8 locale which is"62+ " recommended. You might be able to resolve your"63+ " issue by exporting the following environment"64+ " variables:"65+ )66 )67+ extra.append(" export LC_ALL=C.UTF-8\n export LANG=C.UTF-8")68 else:57- extra += (58- "This system lists some UTF-8 supporting locales that"59- " you can pick from. The following suitable locales"60- f" were discovered: {', '.join(sorted(good_locales))}"69+ extra.append(70+ _(71+ "This system lists some UTF-8 supporting locales"72+ " that you can pick from. The following suitable"73+ " locales were discovered: {locales}"74+ ).format(locales=", ".join(sorted(good_locales)))75 )76 77 bad_locale = None78 for locale in os.environ.get("LC_ALL"), os.environ.get("LANG"):1 unmodified line80 bad_locale = locale81 if locale is not None:82 break83 if bad_locale is not None:70- extra += (71- "\n\nClick discovered that you exported a UTF-8 locale"72- " but the locale system could not pick up from it"73- " because it does not exist. The exported locale is"74- f" {bad_locale!r} but it is not supported"84+ extra.append(85+ _(86+ "Click discovered that you exported a UTF-8 locale"87+ " but the locale system could not pick up from it"88+ " because it does not exist. The exported locale is"89+ " {locale!r} but it is not supported."90+ ).format(locale=bad_locale)91 )92 77- raise RuntimeError(78- "Click will abort further execution because Python was"79- " configured to use ASCII as encoding for the environment."80- " Consult https://click.palletsprojects.com/unicode-support/"81- f" for mitigation steps.{extra}"82- )93+ raise RuntimeError("\n\n".join(extra))modified:src/click/core.py+24 added-19 removed
5 unmodified lines6 from contextlib import contextmanager7 from contextlib import ExitStack8 from functools import update_wrapper9 from gettext import gettext as _10+from gettext import ngettext11 from itertools import repeat12 13 from ._unicodefun import _verify_python_env14 from .exceptions import Abort1185 unmodified lines1200 if not text and self.help:1201 text = make_default_short_help(self.help, limit)1202 1203 if self.deprecated:1203- text = f"(Deprecated) {text}"1204+ text = _("(Deprecated) {text}").format(text=text)1205 1206 return text.strip()1207 1208 def format_help(self, ctx, formatter):17 unmodified lines1226 """Writes the help text to the formatter if it exists."""1227 text = self.help or ""1228 1229 if self.deprecated:1229- text = f"(Deprecated) {text}"1230+ text = _("(Deprecated) {text}").format(text=text)1231 1232 if text:1233 formatter.write_paragraph()1234 8 unmodified lines1243 if rv is not None:1244 opts.append(rv)1245 1246 if opts:1246- with formatter.section("Options"):1247+ with formatter.section(_("Options")):1248 formatter.write_dl(opts)1249 1250 def format_epilog(self, ctx, formatter):1251 """Writes the epilog into the formatter if it exists."""14 unmodified lines1266 value, args = param.handle_parse_result(ctx, opts, args)1267 1268 if args and not ctx.allow_extra_args and not ctx.resilient_parsing:1269 ctx.fail(1269- "Got unexpected extra"1270- f" argument{'s' if len(args) != 1 else ''}"1271- f" ({' '.join(map(make_str, args))})"1270+ ngettext(1271+ "Got unexpected extra argument ({args})",1272+ "Got unexpected extra arguments ({args})",1273+ len(args),1274+ ).format(args=" ".join(map(str, args)))1275 )1276 1277 ctx.args = args1278 return args4 unmodified lines1283 """1284 if self.deprecated:1285 echo(1286 style(1284- _(1285- "DeprecationWarning: The command {self.name!r} is deprecated."1286- ).format(self=self),1287+ _("DeprecationWarning: The command {name!r} is deprecated.").format(1288+ name=self.name1289+ ),1290 fg="red",1291 ),1292 err=True,1293 )185 unmodified lines1479 help = cmd.get_short_help_str(limit)1480 rows.append((subcommand, help))1481 1482 if rows:1480- with formatter.section("Commands"):1483+ with formatter.section(_("Commands")):1484 formatter.write_dl(rows)1485 1486 def parse_args(self, ctx, args):1487 if not args and self.no_args_is_help and not ctx.resilient_parsing:23 unmodified lines1511 # for chained groups.1512 with ctx:1513 super().invoke(ctx)1514 return _process_result([] if self.chain else None)1512- ctx.fail("Missing command.")1515+ ctx.fail(_("Missing command."))1516 1517 # Fetch args back out1518 args = ctx.protected_args + ctx.args1519 ctx.args = []65 unmodified lines1585 # place.1586 if cmd is None and not ctx.resilient_parsing:1587 if split_opt(cmd_name)[0]:1588 self.parse_args(ctx, ctx.args)1586- ctx.fail(f"No such command '{original_cmd_name}'.")1589+ ctx.fail(_("No such command {name!r}.").format(name=original_cmd_name))1590 return cmd.name if cmd else None, cmd, args[1:]1591 1592 def get_command(self, ctx, cmd_name):1593 """Given a context and a command name, this returns a469 unmodified lines2063 if self.multiple2064 else len(value) != self.nargs2065 )2066 ):2064- were = "was" if len(value) == 1 else "were"2067 ctx.fail(2066- f"Argument {self.name!r} takes {self.nargs} values but"2067- f" {len(value)} {were} given."2068+ ngettext(2069+ "Argument {name!r} takes {nargs} values but 1 was given.",2070+ "Argument {name!r} takes {nargs} values but {len} were given.",2071+ len(value),2072+ ).format(name=self.name, nargs=self.nargs, len=len(value))2073 )2074 2075 if self.callback is not None:2076 value = self.callback(ctx, self, value)351 unmodified lines2428 ", ".join(str(d) for d in envvar)2429 if isinstance(envvar, (list, tuple))2430 else envvar2431 )2427- extra.append(f"env var: {var_str}")2432+ extra.append(_("env var: {var}").format(var=var_str))2433 2434 default_value = self.get_default(ctx, call=False)2435 show_default_is_str = isinstance(self.show_default, str)2436 4 unmodified lines2441 default_string = f"({self.show_default})"2442 elif isinstance(default_value, (list, tuple)):2443 default_string = ", ".join(str(d) for d in default_value)2444 elif callable(default_value):2440- default_string = "(dynamic)"2445+ default_string = _("(dynamic)")2446 elif self.is_bool_flag and self.secondary_opts:2447 # For boolean flags that have distinct True/False opts,2448 # use the opt without prefix instead of the value.2449 default_string = split_opt(1 unmodified line2451 )[1]2452 else:2453 default_string = default_value2454 2450- extra.append(f"default: {default_string}")2455+ extra.append(_("default: {default}").format(default=default_string))2456 2457 if isinstance(self.type, _NumberRangeBase):2458 range_str = self.type._describe_range()2459 2460 if range_str:2461 extra.append(range_str)2462 2463 if self.required:2459- extra.append("required")2464+ extra.append(_("required"))2465 if extra:2466 extra_str = ";".join(extra)2467 help = f"{help} [{extra_str}]" if help else f"[{extra_str}]"2468 162 unmodified linesmodified:src/click/decorators.py+2 added-1 removed
303 unmodified lines304 not provided, Click will try to detect it.305 :param prog_name: The name of the CLI to show in the message. If not306 provided, it will be detected from the command.307 :param message: The message to show. The values ``%(prog)s``,308- ``%(package)s``, and ``%(version)s`` are available.308+ ``%(package)s``, and ``%(version)s`` are available. Defaults to309+ ``"%(prog)s, version %(version)s"``.310 :param kwargs: Extra arguments are passed to :func:`option`.311 :raise RuntimeError: ``version`` could not be detected.312 313 .. versionchanged:: 8.0109 unmodified linesmodified:src/click/exceptions.py+42 added-27 removed
1 from gettext import gettext as _2+from gettext import ngettext3 4 from ._compat import filename_to_ui5 from ._compat import get_text_stderr6 from .utils import echo23 unmodified lines30 31 def show(self, file=None):32 if file is None:33 file = get_text_stderr()33- echo(_("Error: {self.format_message()}").format(self=self), file=file)34+ echo(_("Error: {message}").format(message=self.format_message()), file=file)35 36 37 class UsageError(ClickException):38 """An internal exception that signals a usage error. This typically16 unmodified lines55 file = get_text_stderr()56 color = None57 hint = ""58 if self.cmd is not None and self.cmd.get_help_option(self.ctx) is not None:58- hint = (59- f"Try '{self.ctx.command_path}"60- f" {self.ctx.help_option_names[0]}' for help.\n"59+ hint = _("Try '{command} {option}' for help.").format(60+ command=self.ctx.command_path, option=self.ctx.help_option_names[0]61 )62+ hint = f"{hint}\n"63 if self.ctx is not None:64 color = self.ctx.color64- echo(65- _("{usage}\n{hint}").format(usage=self.ctx.get_usage(), hint=hint),66- file=file,67- color=color,68- )65+ echo(f"{self.ctx.get_usage()}\n{hint}", file=file, color=color)66 echo(67 _("Error: {message}").format(message=self.format_message()),68 file=file,69 color=color,28 unmodified lines98 param_hint = self.param_hint99 elif self.param is not None:100 param_hint = self.param.get_error_hint(self.ctx)101 else:105- return f"Invalid value: {self.message}"106- param_hint = _join_param_hints(param_hint)102+ return _("Invalid value: {message}").format(message=self.message)103 108- return f"Invalid value for {param_hint}: {self.message}"104+ return _("Invalid value for {param_hint}: {message}").format(105+ param_hint=_join_param_hints(param_hint), message=self.message106+ )107 108 109 class MissingParameter(BadParameter):110 """Raised if click required an option or argument but it was not19 unmodified lines130 elif self.param is not None:131 param_hint = self.param.get_error_hint(self.ctx)132 else:133 param_hint = None134+135 param_hint = _join_param_hints(param_hint)136+ param_hint = f" {param_hint}" if param_hint else ""137 138 param_type = self.param_type139 if param_type is None and self.param is not None:140 param_type = self.param.param_type_name2 unmodified lines143 if self.param is not None:144 msg_extra = self.param.type.get_missing_message(self.param)145 if msg_extra:146 if msg:147- msg += f". {msg_extra}"147+ msg += f". {msg_extra}"148 else:149 msg = msg_extra150 151- hint_str = f" {param_hint}" if param_hint else ""152- return f"Missing {param_type}{hint_str}.{' ' if msg else ''}{msg or ''}"151+ msg = f" {msg}" if msg else ""152 153+ # Translate param_type for known types.154+ if param_type == "argument":155+ missing = _("Missing argument")156+ elif param_type == "option":157+ missing = _("Missing option")158+ elif param_type == "parameter":159+ missing = _("Missing parameter")160+ else:161+ missing = _("Missing {param_type}").format(param_type=param_type)162+163+ return f"{missing}{param_hint}.{msg}"164+165 def __str__(self):166 if self.message is None:167 param_name = self.param.name if self.param else None157- return _("missing parameter: {param_name}").format(param_name=param_name)168+ return _("Missing parameter: {param_name}").format(param_name=param_name)169 else:170 return self.message171 172 5 unmodified lines178 """179 180 def __init__(self, option_name, message=None, possibilities=None, ctx=None):181 if message is None:171- message = f"no such option: {option_name}"182+ message = _("No such option: {name}").format(name=option_name)183 184 super().__init__(message, ctx)185 self.option_name = option_name186 self.possibilities = possibilities187 188 def format_message(self):178- bits = [self.message]179- if self.possibilities:180- if len(self.possibilities) == 1:181- bits.append(f"Did you mean {self.possibilities[0]}?")182- else:183- possibilities = sorted(self.possibilities)184- bits.append(f"(Possible options: {', '.join(possibilities)})")185- return " ".join(bits)189+ if not self.possibilities:190+ return self.message191 192+ possibility_str = ", ".join(sorted(self.possibilities))193+ suggest = ngettext(194+ "Did you mean {possibility}?",195+ "(Possible options: {possibilities})",196+ len(self.possibilities),197+ ).format(possibility=possibility_str, possibilities=possibility_str)198+ return f"{self.message} {suggest}"199 200+201 class BadOptionUsage(UsageError):202 """Raised if an option is generally supplied but the use of the option203 was incorrect. This is for instance raised if the number of arguments204 for an option is not correct.22 unmodified lines227 228 def __init__(self, filename, hint=None):229 ui_filename = filename_to_ui(filename)230 if hint is None:218- hint = "unknown error"231+ hint = _("unknown error")232 233 super().__init__(hint)234 self.ui_filename = ui_filename235 self.filename = filename236 237 def format_message(self):225- return f"Could not open file {self.ui_filename}: {self.message}"238+ return _("Could not open file {filename!r}: {message}").format(239+ filename=self.ui_filename, message=self.message240+ )241 242 243 class Abort(RuntimeError):244 """An internal signalling exception that signals Click to abort."""13 unmodified linesmodified:src/click/formatting.py+7 added-2 removed
1 import typing as t2 from contextlib import contextmanager3+from gettext import gettext as _4 5 from ._compat import term_len6 from .parser import split_opt7 121 unmodified lines129 def dedent(self):130 """Decreases the indentation."""131 self.current_indent -= self.indent_increment132 132- def write_usage(self, prog, args="", prefix="Usage: "):133+ def write_usage(self, prog, args="", prefix=None):134 """Writes a usage line into the buffer.135 136 :param prog: the program name.137 :param args: whitespace separated list of arguments.137- :param prefix: the prefix for the first line.138+ :param prefix: The prefix for the first line. Defaults to139+ ``"Usage: "``.140 """141+ if prefix is None:142+ prefix = f"{_('Usage:')} "143+144 usage_prefix = f"{prefix:>{self.current_indent}}{prog} "145 text_width = self.width - self.current_indent146 147 if text_width >= (term_len(usage_prefix) + 20):135 unmodified linesmodified:src/click/parser.py+14 added-4 removed
20 unmodified lines21 # maintained by the Python Software Foundation.22 # Copyright 2001-2006 Gregory P. Ward23 # Copyright 2002-2006 Python Software Foundation24 from collections import deque25+from gettext import gettext as _26+from gettext import ngettext27 28 from .exceptions import BadArgumentUsage29 from .exceptions import BadOptionUsage30 from .exceptions import NoSuchOption164 unmodified lines195 if holes == len(value):196 value = None197 elif holes != 0:198 raise BadArgumentUsage(197- f"argument {self.dest} takes {self.nargs} values"199+ _("Argument {name!r} takes {nargs} values.").format(200+ name=self.dest, nargs=self.nargs201+ )202 )203 204 if self.nargs == -1 and self.obj.envvar is not None:205 value = None156 unmodified lines362 363 value = self._get_value_from_state(opt, option, state)364 365 elif explicit_value is not None:362- raise BadOptionUsage(opt, f"{opt} option does not take a value")366+ raise BadOptionUsage(367+ opt, _("Option {name!r} does not take a value.").format(name=opt)368+ )369 370 else:371 value = None372 46 unmodified lines419 if option.obj._flag_needs_value:420 # Option allows omitting the value.421 value = _flag_needs_value422 else:417- n_str = "an argument" if nargs == 1 else f"{nargs} arguments"423 raise BadOptionUsage(419- option_name, f"{option_name} option requires {n_str}."424+ option_name,425+ ngettext(426+ "Option {name!r} requires an argument.",427+ "Option {name!r} requires {nargs} arguments.",428+ nargs,429+ ).format(name=option_name, nargs=nargs),430 )431 elif nargs == 1:432 next_rarg = state.rargs[0]433 45 unmodified linesmodified:src/click/shell_completion.py+6 added-3 removed
1 import os2 import re3 import typing as t4+from gettext import gettext as _5 6 from .core import Argument7 from .core import MultiCommand8 from .core import Option280 unmodified lines289 major, minor = match.groups()290 291 if major < "4" or major == "4" and minor < "4":292 raise RuntimeError(293+ _(292- "Shell completion is not supported for Bash"293- " versions older than 4.4."294+ "Shell completion is not supported for Bash"295+ " versions older than 4.4."296+ )297 )298 else:299 raise RuntimeError(297- "Couldn't detect Bash version, shell completion is not supported."300+ _("Couldn't detect Bash version, shell completion is not supported.")301 )302 303 def source(self):304 self._check_version()241 unmodified linesmodified:src/click/termui.py+9 added-4 removed
160 unmodified lines161 try:162 result = value_proc(value)163 except UsageError as e:164 if hide_input:165- echo(_("Error: the value you entered was invalid"), err=err)165+ echo(_("Error: The value you entered was invalid."), err=err)166 else:167 echo(_("Error: {e.message}").format(e=e), err=err) # noqa: B306168 continue169 if not confirmation_prompt:3 unmodified lines173 if value2:174 break175 if value == value2:176 return result177- echo(_("Error: the two entered values do not match"), err=err)177+ echo(_("Error: The two entered values do not match."), err=err)178 179 180 def confirm(181 text, default=False, abort=False, prompt_suffix=": ", show_default=True, err=False549 unmodified lines731 732 return f()733 734 735-def pause(info="Press any key to continue ...", err=False):735+def pause(info=None, err=False):736 """This command stops execution and waits for the user to press any737 key to continue. This is similar to the Windows batch "pause"738 command. If the program is not run through a terminal, this command739 will instead do nothing.2 unmodified lines742 743 .. versionadded:: 4.0744 Added the `err` parameter.745 746- :param info: the info string to print before pausing.746+ :param info: The message to print before pausing. Defaults to747+ ``"Press any key to continue..."``.748 :param err: if set to message goes to ``stderr`` instead of749 ``stdout``, the same as with echo.750 """751 if not isatty(sys.stdin) or not isatty(sys.stdout):752 return753+754+ if info is None:755+ info = _("Press any key to continue...")756+757 try:758 if info:759 echo(info, nl=False, err=err)760 try:6 unmodified linesmodified:src/click/types.py+59 added-20 removed
1 import os2 import stat3 import typing as t4 from datetime import datetime5+from gettext import gettext as _6+from gettext import ngettext7 8 from ._compat import _get_argv_encoding9 from ._compat import filename_to_ui10 from ._compat import get_filesystem_encoding218 unmodified lines229 # Use square braces to indicate an option or optional argument.230 return f"[{choices_str}]"231 232 def get_missing_message(self, param):231- choice_str = ",\n\t".join(self.choices)232- return f"Choose from:\n\t{choice_str}"233+ return _("Choose from:\n\t{choices}").format(choices=",\n\t".join(self.choices))234 235 def convert(self, value, param, ctx):236 # Match through normalization and case sensitivity237 # first do token_normalize_func, then lowercase18 unmodified lines256 257 if normed_value in normed_choices:258 return normed_choices[normed_value]259 259- one_of = "one of " if len(self.choices) > 1 else ""260- choices_str = ", ".join(repr(c) for c in self.choices)261- self.fail(f"{value!r} is not {one_of}{choices_str}.", param, ctx)260+ choices_str = ", ".join(map(repr, self.choices))261+ self.fail(262+ ngettext(263+ "{value!r} is not {choice}.",264+ "{value!r} is not one of {choices}.",265+ len(self.choices),266+ ).format(value=value, choice=choices_str, choices=choices_str),267+ param,268+ ctx,269+ )270 271 def __repr__(self):272 return f"Choice({list(self.choices)})"273 68 unmodified lines342 343 if converted is not None:344 return converted345 338- plural = "s" if len(self.formats) > 1 else ""339- formats_str = ", ".join(repr(f) for f in self.formats)346+ formats_str = ", ".join(map(repr, self.formats))347 self.fail(341- f"{value!r} does not match the format{plural} {formats_str}.", param, ctx348+ ngettext(349+ "{value!r} does not match the format {format}.",350+ "{value!r} does not match the formats {formats}.",351+ len(self.formats),352+ ).format(value=value, format=formats_str, formats=formats_str),353+ param,354+ ctx,355 )356 357 def __repr__(self):358 return "DateTime"5 unmodified lines364 def convert(self, value, param, ctx):365 try:366 return self._number_class(value)367 except ValueError:355- self.fail(f"{value!r} is not a valid {self.name}.", param, ctx)368+ self.fail(369+ _("{value!r} is not a valid {number_type}.").format(370+ value=value, number_type=self.name371+ ),372+ param,373+ ctx,374+ )375 376 377 class _NumberRangeBase(_NumberParamTypeBase):378 def __init__(self, min=None, max=None, min_open=False, max_open=False, clamp=False):32 unmodified lines411 if gt_max:412 return self._clamp(self.max, -1, self.max_open)413 414 if lt_min or gt_max:396- self.fail(f"{rv} is not in the range {self._describe_range()}.", param, ctx)415+ self.fail(416+ _("{value} is not in the range {range}.").format(417+ value=rv, range=self._describe_range()418+ ),419+ param,420+ ctx,421+ )422 423 return rv424 425 def _clamp(self, bound, dir, open):115 unmodified lines541 542 if norm in {"0", "false", "f", "no", "n", "off"}:543 return False544 520- self.fail(f"{value!r} is not a valid boolean.", param, ctx)545+ self.fail(546+ _("{value!r} is not a valid boolean.").format(value=value), param, ctx547+ )548 549 def __repr__(self):550 return "BOOL"551 11 unmodified lines563 564 try:565 return uuid.UUID(value)566 except ValueError:540- self.fail(f"{value!r} is not a valid UUID.", param, ctx)567+ self.fail(568+ _("{value!r} is not a valid UUID.").format(value=value), param, ctx569+ )570 571 def __repr__(self):572 return "UUID"573 152 unmodified lines726 self.allow_dash = allow_dash727 self.type = path_type728 729 if self.file_okay and not self.dir_okay:701- self.name = "file"730+ self.name = _("file")731 elif self.dir_okay and not self.file_okay:703- self.name = "directory"732+ self.name = _("directory")733 else:705- self.name = "path"734+ self.name = _("path")735 736 def to_info_dict(self):737 info_dict = super().to_info_dict()738 info_dict.update(35 unmodified lines774 except OSError:775 if not self.exists:776 return self.coerce_path_result(rv)777 self.fail(749- f"{self.name.title()} {filename_to_ui(value)!r} does not exist.",778+ _("{name} {filename!r} does not exist.").format(779+ name=self.name.title(), filename=filename_to_ui(value)780+ ),781 param,782 ctx,783 )784 785 if not self.file_okay and stat.S_ISREG(st.st_mode):786 self.fail(756- f"{self.name.title()} {filename_to_ui(value)!r} is a file.",787+ _("{name} {filename!r} is a file.").format(788+ name=self.name.title(), filename=filename_to_ui(value)789+ ),790 param,791 ctx,792 )793 if not self.dir_okay and stat.S_ISDIR(st.st_mode):794 self.fail(762- f"{self.name.title()} {filename_to_ui(value)!r} is a directory.",795+ _("{name} {filename!r} is a directory.").format(796+ name=self.name.title(), filename=filename_to_ui(value)797+ ),798 param,799 ctx,800 )801 if self.writable and not os.access(value, os.W_OK):802 self.fail(768- f"{self.name.title()} {filename_to_ui(value)!r} is not writable.",803+ _("{name} {filename!r} is not writable.").format(804+ name=self.name.title(), filename=filename_to_ui(value)805+ ),806 param,807 ctx,808 )809 if self.readable and not os.access(value, os.R_OK):810 self.fail(774- f"{self.name.title()} {filename_to_ui(value)!r} is not readable.",811+ _("{name} {filename!r} is not readable.").format(812+ name=self.name.title(), filename=filename_to_ui(value)813+ ),814 param,815 ctx,816 )817 152 unmodified linesmodified:tests/test_arguments.py+2 added-2 removed
228 unmodified lines229 230 with pytest.raises(click.MissingParameter) as excinfo:231 click.Argument(["a"], required=True).process_value(ctx, None)232 233- assert str(excinfo.value) == "missing parameter: a"233+ assert str(excinfo.value) == "Missing parameter: a"234 235 236 def test_implicit_non_required(runner):237 @click.command()62 unmodified lines300 assert result.output.strip() == "7"301 302 result = runner.invoke(cmd, ["3"])303 assert result.exception is not None304- assert "argument a takes 2 values" in result.output304+ assert "Argument 'a' takes 2 values." in result.output305 306 307 def test_multiple_param_decls_not_allowed(runner):308 with pytest.raises(TypeError):66 unmodified linesmodified:tests/test_basic.py+1 added-1 removed
118 unmodified lines119 assert "FOO:[42]" in result.output120 121 result = runner.invoke(cli, ["--foo"])122 assert result.exception123- assert "--foo option requires an argument" in result.output123+ assert "Option '--foo' requires an argument." in result.output124 125 result = runner.invoke(cli, ["--foo="])126 assert not result.exception127 assert "FOO:[]" in result.output422 unmodified linesmodified:tests/test_options.py+2 added-2 removed
81 unmodified lines82 pass83 84 result = runner.invoke(cli, [unknown_flag])85 assert result.exception86- assert f"no such option: {unknown_flag}" in result.output86+ assert f"No such option: {unknown_flag}" in result.output87 88 89 @pytest.mark.parametrize(90 ("value", "expect"),349 unmodified lines440 441 with pytest.raises(click.MissingParameter) as excinfo:442 click.Option(["-a"], required=True).process_value(ctx, None)443 444- assert str(excinfo.value) == "missing parameter: a"444+ assert str(excinfo.value) == "Missing parameter: a"445 446 447 def test_missing_choice(runner):448 @click.command()289 unmodified linesmodified:tests/test_termui.py+1 added-1 removed
374 unmodified lines375 @pytest.mark.parametrize(376 ("prompt_required", "required", "args", "expect"),377 [378 (True, False, None, "prompt"),379- (True, False, ["-v"], "-v option requires an argument"),379+ (True, False, ["-v"], "Option '-v' requires an argument."),380 (False, True, None, "prompt"),381 (False, True, ["-v"], "prompt"),382 ],383 )64 unmodified linesmodified:CHANGES.rst+3 added-1 removed
195 unmodified lines196 well as in the short help. The notice is not in all caps.197 :issue:`1791`198 - When taking arguments from ``sys.argv`` on Windows, glob patterns,199 user dir, and env vars are expanded. :issue:`1096`200-- Wrapped public messages with ``_(gettext)`` for i18n support. :issue:`303`200+- Marked messages shown by the CLI with ``gettext()`` to allow201+ applications to translate Click's built-in strings. :issue:`303`202 203+204 Version 7.1.2205 -------------206 207 Released 2020-04-27633 unmodified lines