Localisation of more strings (#2902)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Eric Platon · committed by GitHub · parent 73e1550 · Browse files · 9 files·+54 added−32 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: Carmen Bianca BAKKER <carmen@carmenbianca.eu>
Diff stats
9 files+54 added−32 removed
- other:+54 added−32 removed
Provenance
- Commit
5b9630f- Tree
499a730- Author
Eric Platon <__ic@tutamail.com>- Committer
GitHub <noreply@github.com>- Parent
73e1550
9 files changed+54 added−32 removed
modified:src/click/_termui_impl.py+7 added-1 removed
171 unmodified lines172 t //= 60173 hours = t % 24174 t //= 24175 if t > 0:176- return f"{t}d {hours:02}:{minutes:02}:{seconds:02}"176+ return "{d}{day_label} {h:02}:{m:02}:{s:02}".format(177+ d=t,178+ day_label=_("d"),179+ h=hours,180+ m=minutes,181+ s=seconds,182+ )183 else:184 return f"{hours:02}:{minutes:02}:{seconds:02}"185 return ""186 711 unmodified linesmodified:src/click/_winconsole.py+3 added-2 removed
26 unmodified lines27 from ctypes.wintypes import DWORD28 from ctypes.wintypes import HANDLE29 from ctypes.wintypes import LPCWSTR30 from ctypes.wintypes import LPWSTR31+from gettext import gettext as _32 33 from ._compat import _NonClosingTextIOWrapper34 35 assert sys.platform == "win32"116 unmodified lines152 if GetLastError() == ERROR_OPERATION_ABORTED:153 # wait for KeyboardInterrupt154 time.sleep(0.1)155 if not rv:155- raise OSError(f"Windows error: {GetLastError()}")156+ raise OSError(_("Windows error: {error}").format(error=GetLastError()))157 158 if buffer[0] == EOF:159 return 0160 return 2 * code_units_read.value8 unmodified lines169 if errno == ERROR_SUCCESS:170 return "ERROR_SUCCESS"171 elif errno == ERROR_NOT_ENOUGH_MEMORY:172 return "ERROR_NOT_ENOUGH_MEMORY"172- return f"Windows error {errno}"173+ return _("Windows error: {error}").format(error=errno)174 175 def write(self, b: Buffer) -> int:176 bytes_to_be_written = len(b)177 buf = get_buffer(b)120 unmodified linesmodified:src/click/core.py+25 added-19 removed
1134 unmodified lines1135 else:1136 text = ""1137 1138 if self.deprecated:1139+ localised_deprectated = _("deprecated").upper()1140 deprecated_message = (1140- f"(DEPRECATED: {self.deprecated})"1141+ f"({localised_deprectated}: {self.deprecated})"1142 if isinstance(self.deprecated, str)1142- else "(DEPRECATED)"1143+ else f"({localised_deprectated})"1144 )1144- text = _("{text} {deprecated_message}").format(1145- text=text, deprecated_message=deprecated_message1146- )1145+ text = f"{_(text)} {deprecated_message}"1146 1147 return text.strip()1148 1149 def format_help(self, ctx: Context, formatter: HelpFormatter) -> None:21 unmodified lines1171 else:1172 text = ""1173 1174 if self.deprecated:1175+ localised_deprectated = _("deprecated").upper()1176 deprecated_message = (1177- f"(DEPRECATED: {self.deprecated})"1177+ f"({localised_deprectated}: {self.deprecated})"1178 if isinstance(self.deprecated, str)1179- else "(DEPRECATED)"1179+ else f"({localised_deprectated})"1180 )1181- text = _("{text} {deprecated_message}").format(1182- text=text, deprecated_message=deprecated_message1183- )1181+ text = f"{_(text)} {deprecated_message}"1182 1183 if text:1184 formatter.write_paragraph()1185 1795 unmodified lines2981 2982 for decl in decls:2983 if decl.isidentifier():2984 if name is not None:2987- raise TypeError(f"Name '{name}' defined twice")2985+ raise TypeError(_("Name '{name}' defined twice").format(name=name))2986 name = decl2987 else:2988 split_char = ";" if decl[:1] == "/" else "/"2989 if split_char in decl:6 unmodified lines2996 if second:2997 secondary_opts.append(second.lstrip())2998 if first == second:2999 raise ValueError(3000+ _(3002- f"Boolean option {decl!r} cannot use the"3003- " same flag for true/false."3001+ "Boolean option {decl!r} cannot use the"3002+ " same flag for true/false."3003+ ).format(decl=decl)3004 )3005 else:3006 possible_names.append(_split_opt(decl))3007 opts.append(decl)7 unmodified lines3015 if name is None:3016 if not expose_value:3017 return "", opts, secondary_opts3018 raise TypeError(3019+ _(3019- f"Could not determine name for option with declarations {decls!r}"3020+ "Could not determine name for option with declarations {decls!r}"3021+ ).format(decls=decls)3022 )3023 3024 if not opts and not secondary_opts:3025 raise TypeError(3026+ _(3024- f"No options defined but a name was passed ({name})."3025- " Did you mean to declare an argument instead? Did"3026- f" you mean to pass '--{name}'?"3027+ "No options defined but a name was passed ({name})."3028+ " Did you mean to declare an argument instead? Did"3029+ " you mean to pass '--{name}'?"3030+ ).format(name=name)3031 )3032 3033 return name, opts, secondary_opts3034 423 unmodified lines3458 name = arg = decls[0]3459 name = name.replace("-", "_").lower()3460 else:3461 raise TypeError(3462+ _(3458- "Arguments take exactly one parameter declaration, got"3459- f" {len(decls)}: {decls}."3463+ "Arguments take exactly one parameter declaration, got"3464+ " {length}: {decls}."3465+ ).format(length=len(decls), decls=decls)3466 )3467 return name, [arg], []3468 3469 def get_usage_pieces(self, ctx: Context) -> list[str]:33 unmodified linesmodified:src/click/decorators.py+2 added-2 removed
394 unmodified lines395 396 kwargs.setdefault("is_flag", True)397 kwargs.setdefault("callback", callback)398 kwargs.setdefault("expose_value", False)399- kwargs.setdefault("prompt", "Do you want to continue?")400- kwargs.setdefault("help", "Confirm the action without prompting.")399+ kwargs.setdefault("prompt", _("Do you want to continue?"))400+ kwargs.setdefault("help", _("Confirm the action without prompting."))401 return option(*param_decls, **kwargs)402 403 404 def password_option(*param_decls: str, **kwargs: t.Any) -> t.Callable[[FC], FC]:147 unmodified linesmodified:src/click/formatting.py+1 added-1 removed
151 unmodified lines152 :param prefix: The prefix for the first line. Defaults to153 ``"Usage: "``.154 """155 if prefix is None:156- prefix = f"{_('Usage:')} "156+ prefix = "{usage} ".format(usage=_("Usage:"))157 158 usage_prefix = f"{prefix:>{self.current_indent}}{prog} "159 text_width = self.width - self.current_indent160 141 unmodified linesmodified:src/click/parser.py+5 added-1 removed
139 unmodified lines140 141 for opt in opts:142 prefix, value = _split_opt(opt)143 if not prefix:144- raise ValueError(f"Invalid start character for option ({opt})")144+ raise ValueError(145+ _("Invalid start character for option ({option})").format(146+ option=opt147+ )148+ )149 self.prefixes.add(prefix[0])150 if len(prefix) == 1 and len(value) == 1:151 self._short_opts.append(opt)152 else:381 unmodified linesmodified:src/click/termui.py+2 added-2 removed
650 unmodified lines651 if fg:652 try:653 bits.append(f"\033[{_interpret_color(fg)}m")654 except KeyError:655- raise TypeError(f"Unknown color {fg!r}") from None655+ raise TypeError(_("Unknown color {colour!r}").format(colour=fg)) from None656 657 if bg:658 try:659 bits.append(f"\033[{_interpret_color(bg, 10)}m")660 except KeyError:661- raise TypeError(f"Unknown color {bg!r}") from None661+ raise TypeError(_("Unknown color {colour!r}").format(colour=bg)) from None662 663 if bold is not None:664 bits.append(f"\033[{1 if bold else 22}m")665 if dim is not None:256 unmodified linesmodified:src/click/types.py+6 added-2 removed
388 unmodified lines389 len(self.choices),390 ).format(value=value, choice=choices_str, choices=choices_str)391 392 def __repr__(self) -> str:393- return f"Choice({list(self.choices)})"393+ return _("Choice({choices})").format(choices=list(self.choices))394 395 def shell_complete(396 self, ctx: Context, param: Parameter, incomplete: str397 ) -> list[CompletionItem]:489 unmodified lines887 ctx.call_on_close(safecall(f.flush))888 889 return f890 except OSError as e:891- self.fail(f"'{format_filename(value)}': {e.strerror}", param, ctx)891+ self.fail(892+ f"'{format_filename(value)}': {e.strerror}",893+ param,894+ ctx,895+ )896 897 def shell_complete(898 self, ctx: Context, param: Parameter, incomplete: str899 ) -> list[CompletionItem]:397 unmodified linesmodified:src/click/utils.py+3 added-2 removed
4 unmodified lines5 import re6 import sys7 import typing as t8 from functools import update_wrapper9+from gettext import gettext as _10 from types import ModuleType11 from types import TracebackType12 13 from ._compat import _default_text_stderr319 unmodified lines333 ``'stdout'`` and ``'stderr'``334 """335 opener = binary_streams.get(name)336 if opener is None:336- raise TypeError(f"Unknown standard stream '{name}'")337+ raise TypeError(_("Unknown standard stream '{name}'").format(name=name))338 return opener()339 340 341 def get_text_stream(12 unmodified lines354 :param errors: overrides the default error mode.355 """356 opener = text_streams.get(name)357 if opener is None:357- raise TypeError(f"Unknown standard stream '{name}'")358+ raise TypeError(_("Unknown standard stream '{name}'").format(name=name))359 return opener(encoding, errors)360 361 362 def open_file(269 unmodified lines