Marco Ricci commited on 2024-12-31 16:03:01
Zeige 1 geänderte Dateien mit 64 Einfügungen und 57 Löschungen.
... | ... |
@@ -78,6 +78,11 @@ def _prepare_translatable( |
78 | 78 |
assert '%' not in msg or bool( |
79 | 79 |
flags & {'python-format', 'no-python-format'} |
80 | 80 |
), f'Missing flag for how to deal with percent character in {msg!r}' |
81 |
+ assert ( |
|
82 |
+ not flags & {'python-format', 'python-brace-format'} |
|
83 |
+ or '%' in msg |
|
84 |
+ or '{' in msg |
|
85 |
+ ), f'Missing format string parameters in {msg!r}' |
|
81 | 86 |
return TranslatableString(msg, plural_msg, context, comments, flags) |
82 | 87 |
|
83 | 88 |
|
... | ... |
@@ -292,9 +297,9 @@ class Label(enum.Enum): |
292 | 297 |
) |
293 | 298 |
EXPORT_VAULT_FORMAT_HELP_TEXT = _prepare_translatable( |
294 | 299 |
comments=r""" |
295 |
- TRANSLATORS: The defaults_hint is the text in |
|
296 |
- EXPORT_VAULT_FORMAT_DEFAULTS_HELP_TEXT, the metavar is in |
|
297 |
- EXPORT_VAULT_FORMAT_METAVAR_FMT. |
|
300 |
+ TRANSLATORS: The defaults_hint is |
|
301 |
+ Label.EXPORT_VAULT_FORMAT_DEFAULTS_HELP_TEXT, the metavar is |
|
302 |
+ Label.EXPORT_VAULT_FORMAT_METAVAR_FMT. |
|
298 | 303 |
""", |
299 | 304 |
msg=r""" |
300 | 305 |
try the following storage format {metavar!s}; may be |
... | ... |
@@ -317,9 +322,9 @@ class Label(enum.Enum): |
317 | 322 |
) |
318 | 323 |
EXPORT_VAULT_KEY_HELP_TEXT = _prepare_translatable( |
319 | 324 |
comments=r""" |
320 |
- TRANSLATORS: The defaults_hint is the text in |
|
321 |
- EXPORT_VAULT_KEY_DEFAULTS_HELP_TEXT, the metavar is in |
|
322 |
- EXPORT_VAULT_KEY_METAVAR_K. |
|
325 |
+ TRANSLATORS: The defaults_hint is |
|
326 |
+ Label.EXPORT_VAULT_KEY_DEFAULTS_HELP_TEXT, the metavar is |
|
327 |
+ Label.EXPORT_VAULT_KEY_METAVAR_K. |
|
323 | 328 |
""", |
324 | 329 |
msg=r""" |
325 | 330 |
use {metavar!s} as the storage master key {defaults_hint!s} |
... | ... |
@@ -360,8 +365,8 @@ class Label(enum.Enum): |
360 | 365 |
) |
361 | 366 |
DERIVEPASSPHRASE_VAULT_LENGTH_HELP_TEXT = _prepare_translatable( |
362 | 367 |
comments=r""" |
363 |
- TRANSLATORS: The metavar is specified in |
|
364 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
368 |
+ TRANSLATORS: The metavar is |
|
369 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
365 | 370 |
""", |
366 | 371 |
msg='ensure a passphrase length of {metavar!s} characters', |
367 | 372 |
context='help text (option one-line description)', |
... | ... |
@@ -369,8 +374,8 @@ class Label(enum.Enum): |
369 | 374 |
) |
370 | 375 |
DERIVEPASSPHRASE_VAULT_REPEAT_HELP_TEXT = _prepare_translatable( |
371 | 376 |
comments=r""" |
372 |
- TRANSLATORS: The metavar is specified in |
|
373 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
377 |
+ TRANSLATORS: The metavar is |
|
378 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
374 | 379 |
""", |
375 | 380 |
msg='forbid any run of {metavar!s} identical characters', |
376 | 381 |
context='help text (option one-line description)', |
... | ... |
@@ -378,8 +383,8 @@ class Label(enum.Enum): |
378 | 383 |
) |
379 | 384 |
DERIVEPASSPHRASE_VAULT_LOWER_HELP_TEXT = _prepare_translatable( |
380 | 385 |
comments=r""" |
381 |
- TRANSLATORS: The metavar is specified in |
|
382 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
386 |
+ TRANSLATORS: The metavar is |
|
387 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
383 | 388 |
""", |
384 | 389 |
msg='ensure at least {metavar!s} lowercase characters', |
385 | 390 |
context='help text (option one-line description)', |
... | ... |
@@ -387,8 +392,8 @@ class Label(enum.Enum): |
387 | 392 |
) |
388 | 393 |
DERIVEPASSPHRASE_VAULT_UPPER_HELP_TEXT = _prepare_translatable( |
389 | 394 |
comments=r""" |
390 |
- TRANSLATORS: The metavar is specified in |
|
391 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
395 |
+ TRANSLATORS: The metavar is |
|
396 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
392 | 397 |
""", |
393 | 398 |
msg='ensure at least {metavar!s} uppercase characters', |
394 | 399 |
context='help text (option one-line description)', |
... | ... |
@@ -396,8 +401,8 @@ class Label(enum.Enum): |
396 | 401 |
) |
397 | 402 |
DERIVEPASSPHRASE_VAULT_NUMBER_HELP_TEXT = _prepare_translatable( |
398 | 403 |
comments=r""" |
399 |
- TRANSLATORS: The metavar is specified in |
|
400 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
404 |
+ TRANSLATORS: The metavar is |
|
405 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
401 | 406 |
""", |
402 | 407 |
msg='ensure at least {metavar!s} digits', |
403 | 408 |
context='help text (option one-line description)', |
... | ... |
@@ -405,8 +410,8 @@ class Label(enum.Enum): |
405 | 410 |
) |
406 | 411 |
DERIVEPASSPHRASE_VAULT_SPACE_HELP_TEXT = _prepare_translatable( |
407 | 412 |
comments=r""" |
408 |
- TRANSLATORS: The metavar is specified in |
|
409 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
413 |
+ TRANSLATORS: The metavar is |
|
414 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
410 | 415 |
""", |
411 | 416 |
msg='ensure at least {metavar!s} spaces', |
412 | 417 |
context='help text (option one-line description)', |
... | ... |
@@ -414,8 +419,8 @@ class Label(enum.Enum): |
414 | 419 |
) |
415 | 420 |
DERIVEPASSPHRASE_VAULT_DASH_HELP_TEXT = _prepare_translatable( |
416 | 421 |
comments=r""" |
417 |
- TRANSLATORS: The metavar is specified in |
|
418 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
422 |
+ TRANSLATORS: The metavar is |
|
423 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
419 | 424 |
""", |
420 | 425 |
msg='ensure at least {metavar!s} "-" or "_" characters', |
421 | 426 |
context='help text (option one-line description)', |
... | ... |
@@ -423,8 +428,8 @@ class Label(enum.Enum): |
423 | 428 |
) |
424 | 429 |
DERIVEPASSPHRASE_VAULT_SYMBOL_HELP_TEXT = _prepare_translatable( |
425 | 430 |
comments=r""" |
426 |
- TRANSLATORS: The metavar is specified in |
|
427 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
431 |
+ TRANSLATORS: The metavar is |
|
432 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
428 | 433 |
""", |
429 | 434 |
msg='ensure at least {metavar!s} symbol characters', |
430 | 435 |
context='help text (option one-line description)', |
... | ... |
@@ -461,8 +466,8 @@ class Label(enum.Enum): |
461 | 466 |
) |
462 | 467 |
DERIVEPASSPHRASE_VAULT_EXPORT_HELP_TEXT = _prepare_translatable( |
463 | 468 |
comments=""" |
464 |
- TRANSLATORS: The metavar is specified in |
|
465 |
- STORAGE_MANAGEMENT_METAVAR_SERVICE. |
|
469 |
+ TRANSLATORS: The metavar is |
|
470 |
+ Label.STORAGE_MANAGEMENT_METAVAR_SERVICE. |
|
466 | 471 |
""", |
467 | 472 |
msg='export all saved settings to {metavar!s}', |
468 | 473 |
context='help text (option one-line description)', |
... | ... |
@@ -470,8 +475,8 @@ class Label(enum.Enum): |
470 | 475 |
) |
471 | 476 |
DERIVEPASSPHRASE_VAULT_IMPORT_HELP_TEXT = _prepare_translatable( |
472 | 477 |
comments=""" |
473 |
- TRANSLATORS: The metavar is specified in |
|
474 |
- STORAGE_MANAGEMENT_METAVAR_SERVICE. |
|
478 |
+ TRANSLATORS: The metavar is |
|
479 |
+ Label.STORAGE_MANAGEMENT_METAVAR_SERVICE. |
|
475 | 480 |
""", |
476 | 481 |
msg='import saved settings from {metavar!s}', |
477 | 482 |
context='help text (option one-line description)', |
... | ... |
@@ -485,7 +490,6 @@ class Label(enum.Enum): |
485 | 490 |
""", |
486 | 491 |
msg='overwrite or merge (default) the existing configuration', |
487 | 492 |
context='help text (option one-line description)', |
488 |
- flags='python-brace-format', |
|
489 | 493 |
) |
490 | 494 |
DERIVEPASSPHRASE_VAULT_UNSET_HELP_TEXT = _prepare_translatable( |
491 | 495 |
comments=""" |
... | ... |
@@ -518,15 +522,15 @@ class Label(enum.Enum): |
518 | 522 |
) |
519 | 523 |
EXPORT_VAULT_KEY_METAVAR_K = _prepare_translatable( |
520 | 524 |
comments=r""" |
521 |
- TRANSLATORS: See EXPORT_VAULT_KEY_HELP_TEXT. |
|
525 |
+ TRANSLATORS: See Label.EXPORT_VAULT_KEY_HELP_TEXT. |
|
522 | 526 |
""", |
523 | 527 |
msg='K', |
524 | 528 |
context='help text, metavar (export vault subcommand)', |
525 | 529 |
) |
526 | 530 |
EXPORT_VAULT_METAVAR_PATH = _prepare_translatable( |
527 | 531 |
comments=r""" |
528 |
- TRANSLATORS: This metavar is also used in multiple one-line help |
|
529 |
- texts, as "path_metavar". |
|
532 |
+ TRANSLATORS: Used as "path_metavar" in |
|
533 |
+ Label.DERIVEPASSPHRASE_EXPORT_VAULT_02 and others. |
|
530 | 534 |
""", |
531 | 535 |
msg='PATH', |
532 | 536 |
context='help text, metavar (export vault subcommand)', |
... | ... |
@@ -543,7 +547,7 @@ class Label(enum.Enum): |
543 | 547 |
TRANSLATORS: This metavar is also used in multiple one-line help |
544 | 548 |
texts. |
545 | 549 |
""", |
546 |
- msg='NUMBER', |
|
550 |
+ msg='PATH', |
|
547 | 551 |
context='help text, metavar (storage management group)', |
548 | 552 |
) |
549 | 553 |
VAULT_METAVAR_SERVICE = _prepare_translatable( |
... | ... |
@@ -561,8 +565,8 @@ class Label(enum.Enum): |
561 | 565 |
) |
562 | 566 |
PASSPHRASE_GENERATION_EPILOG = _prepare_translatable( |
563 | 567 |
comments=r""" |
564 |
- TRANSLATORS: The metavar is specified in |
|
565 |
- PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
568 |
+ TRANSLATORS: The metavar is |
|
569 |
+ Label.PASSPHRASE_GENERATION_METAVAR_NUMBER. |
|
566 | 570 |
""", |
567 | 571 |
msg=r""" |
568 | 572 |
Use {metavar!s}=0 to exclude a character type from the output. |
... | ... |
@@ -572,8 +576,8 @@ class Label(enum.Enum): |
572 | 576 |
) |
573 | 577 |
STORAGE_MANAGEMENT_EPILOG = _prepare_translatable( |
574 | 578 |
comments=r""" |
575 |
- TRANSLATORS: The metavar is specified in |
|
576 |
- STORAGE_MANAGEMENT_METAVAR_PATH. |
|
579 |
+ TRANSLATORS: The metavar is |
|
580 |
+ Label.STORAGE_MANAGEMENT_METAVAR_PATH. |
|
577 | 581 |
""", |
578 | 582 |
msg=r""" |
579 | 583 |
Using "-" as {metavar!s} for standard input/standard output |
... | ... |
@@ -698,8 +702,8 @@ class WarnMsgTemplate(enum.Enum): |
698 | 702 |
) |
699 | 703 |
FAILED_TO_MIGRATE_CONFIG = _prepare_translatable( |
700 | 704 |
comments=r""" |
701 |
- TRANSLATORS: The error message is usually supplied by the |
|
702 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
705 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
706 |
+ (errno/strerror). |
|
703 | 707 |
""", |
704 | 708 |
msg='Failed to migrate to {path!r}: {error!s}: {filename!r}.', |
705 | 709 |
context='warning message', |
... | ... |
@@ -763,7 +767,7 @@ class WarnMsgTemplate(enum.Enum): |
763 | 767 |
msg=r""" |
764 | 768 |
Using deprecated v0.1-style config file {old!r}, instead of |
765 | 769 |
v0.2-style {new!r}. Support for v0.1-style config filenames |
766 |
- will be removed in v1.0., |
|
770 |
+ will be removed in v1.0. |
|
767 | 771 |
""", |
768 | 772 |
comments='', |
769 | 773 |
context='deprecation warning message', |
... | ... |
@@ -808,23 +812,26 @@ class ErrMsgTemplate(enum.Enum): |
808 | 812 |
) |
809 | 813 |
CANNOT_CONNECT_TO_AGENT = _prepare_translatable( |
810 | 814 |
comments=r""" |
811 |
- TRANSLATORS: The error message is usually supplied by the |
|
812 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
815 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
816 |
+ (errno/strerror). |
|
813 | 817 |
""", |
814 | 818 |
msg='Cannot connect to the SSH agent: {error!s}: {filename!r}.', |
815 | 819 |
context='error message', |
816 | 820 |
flags='python-brace-format', |
817 | 821 |
) |
818 | 822 |
CANNOT_DECODEIMPORT_VAULT_SETTINGS = _prepare_translatable( |
823 |
+ comments=r""" |
|
824 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
825 |
+ (errno/strerror). |
|
826 |
+ """, |
|
819 | 827 |
msg='Cannot import vault settings: cannot decode JSON: {error!s}.', |
820 |
- comments='', |
|
821 | 828 |
context='error message', |
822 | 829 |
flags='python-brace-format', |
823 | 830 |
) |
824 | 831 |
CANNOT_EXPORT_VAULT_SETTINGS = _prepare_translatable( |
825 | 832 |
comments=r""" |
826 |
- TRANSLATORS: The error message is usually supplied by the |
|
827 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
833 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
834 |
+ (errno/strerror). |
|
828 | 835 |
""", |
829 | 836 |
msg='Cannot export vault settings: {error!s}: {filename!r}.', |
830 | 837 |
context='error message', |
... | ... |
@@ -832,8 +839,8 @@ class ErrMsgTemplate(enum.Enum): |
832 | 839 |
) |
833 | 840 |
CANNOT_IMPORT_VAULT_SETTINGS = _prepare_translatable( |
834 | 841 |
comments=r""" |
835 |
- TRANSLATORS: The error message is usually supplied by the |
|
836 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
842 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
843 |
+ (errno/strerror). |
|
837 | 844 |
""", |
838 | 845 |
msg='Cannot import vault settings: {error!s}: {filename!r}.', |
839 | 846 |
context='error message', |
... | ... |
@@ -841,8 +848,8 @@ class ErrMsgTemplate(enum.Enum): |
841 | 848 |
) |
842 | 849 |
CANNOT_LOAD_USER_CONFIG = _prepare_translatable( |
843 | 850 |
comments=r""" |
844 |
- TRANSLATORS: The error message is usually supplied by the |
|
845 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
851 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
852 |
+ (errno/strerror). |
|
846 | 853 |
""", |
847 | 854 |
msg='Cannot load user config: {error!s}: {filename!r}.', |
848 | 855 |
context='error message', |
... | ... |
@@ -850,8 +857,8 @@ class ErrMsgTemplate(enum.Enum): |
850 | 857 |
) |
851 | 858 |
CANNOT_LOAD_VAULT_SETTINGS = _prepare_translatable( |
852 | 859 |
comments=r""" |
853 |
- TRANSLATORS: The error message is usually supplied by the |
|
854 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
860 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
861 |
+ (errno/strerror). |
|
855 | 862 |
""", |
856 | 863 |
msg='Cannot load vault settings: {error!s}: {filename!r}.', |
857 | 864 |
context='error message', |
... | ... |
@@ -875,8 +882,8 @@ class ErrMsgTemplate(enum.Enum): |
875 | 882 |
) |
876 | 883 |
CANNOT_STORE_VAULT_SETTINGS = _prepare_translatable( |
877 | 884 |
comments=r""" |
878 |
- TRANSLATORS: The error message is usually supplied by the |
|
879 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
885 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
886 |
+ (errno/strerror). |
|
880 | 887 |
""", |
881 | 888 |
msg='Cannot store vault settings: {error!s}: {filename!r}.', |
882 | 889 |
context='error message', |
... | ... |
@@ -909,8 +916,8 @@ class ErrMsgTemplate(enum.Enum): |
909 | 916 |
) |
910 | 917 |
INVALID_USER_CONFIG = _prepare_translatable( |
911 | 918 |
comments=r""" |
912 |
- TRANSLATORS: The error message is usually supplied by the |
|
913 |
- operating system, e.g. ENOENT/"No such file or directory". |
|
919 |
+ TRANSLATORS: "error" is supplied by the operating system |
|
920 |
+ (errno/strerror). |
|
914 | 921 |
""", |
915 | 922 |
msg=r""" |
916 | 923 |
The user configuration file is invalid. {error!s}: {filename!r}. |
... | ... |
@@ -976,7 +983,7 @@ class ErrMsgTemplate(enum.Enum): |
976 | 983 |
PARAMS_NEEDS_SERVICE_OR_CONFIG = _prepare_translatable( |
977 | 984 |
comments=r""" |
978 | 985 |
TRANSLATORS: The param is a long-form command-line option name, |
979 |
- and the metavar is given in VAULT_METAVAR_SERVICE. |
|
986 |
+ the metavar is Label.VAULT_METAVAR_SERVICE. |
|
980 | 987 |
""", |
981 | 988 |
msg='{param!s} requires a {service_metavar!s} or --config.', |
982 | 989 |
context='error message', |
... | ... |
@@ -985,7 +992,7 @@ class ErrMsgTemplate(enum.Enum): |
985 | 992 |
PARAMS_NEEDS_SERVICE = _prepare_translatable( |
986 | 993 |
comments=r""" |
987 | 994 |
TRANSLATORS: The param is a long-form command-line option name, |
988 |
- and the metavar is given in VAULT_METAVAR_SERVICE. |
|
995 |
+ the metavar is Label.VAULT_METAVAR_SERVICE. |
|
989 | 996 |
""", |
990 | 997 |
msg='{param!s} requires a {service_metavar!s}.', |
991 | 998 |
context='error message', |
... | ... |
@@ -994,7 +1001,7 @@ class ErrMsgTemplate(enum.Enum): |
994 | 1001 |
PARAMS_NO_SERVICE = _prepare_translatable( |
995 | 1002 |
comments=r""" |
996 | 1003 |
TRANSLATORS: The param is a long-form command-line option name, |
997 |
- and the metavar is given in VAULT_METAVAR_SERVICE. |
|
1004 |
+ the metavar is Label.VAULT_METAVAR_SERVICE. |
|
998 | 1005 |
""", |
999 | 1006 |
msg='{param!s} does not take a {service_metavar!s} argument.', |
1000 | 1007 |
context='error message', |
... | ... |
@@ -1002,7 +1009,7 @@ class ErrMsgTemplate(enum.Enum): |
1002 | 1009 |
) |
1003 | 1010 |
SERVICE_REQUIRED = _prepare_translatable( |
1004 | 1011 |
comments=r""" |
1005 |
- TRANSLATORS: The metavar is given in VAULT_METAVAR_SERVICE. |
|
1012 |
+ TRANSLATORS: The metavar is Label.VAULT_METAVAR_SERVICE. |
|
1006 | 1013 |
""", |
1007 | 1014 |
msg='Deriving a passphrase requires a {service_metavar!s}.', |
1008 | 1015 |
context='error message', |
1009 | 1016 |