Add new help and error messages with metavars expanded inline
Marco Ricci

Marco Ricci commited on 2026-08-16 08:52:13
Zeige 1 geänderte Dateien mit 109 Einfügungen und 2 Löschungen.


For all texts that aren't one-line option descriptions, add versions of
the text where the metavar is expanded inline, instead of referencing
a different translation string inline.  If multiple texts need to use
the same metavar consistently, pick one of them, and reference that
canonical entry in the other entries' commentary.

This is partly based on search engine/AI feedback on how other projects
solve the problem of wanting to explain mini-formats or other
conventions common to multiple messages to translators: there is no
place to put (machine-readable) references or common explanation, so it
is typical instead to refer inline in the translation commentary to
a canonical entry that contains longer-form explanation instead.  This
is rather awkward to work with if there are multiple layers of expansion
(metavars) in the messages, so it is probably easier on the translators
to include the metavar inline and just note that "canonical text X" uses
the same metavar.  Of course, the canonical text should be short enough
to be easily included inline in the commentary.
... ...
@@ -639,8 +639,8 @@ def commented(comments: str = "", /) -> TranslatableStringConstructor:
639 639
 class Label(enum.Enum):
640 640
     """Labels for the `derivepassphrase` command-line.
641 641
 
642
-    Includes help text (long-form and short-form), help metavar names,
643
-    diagnostic labels and interactive prompts.
642
+    Includes help text (long-form and short-form), diagnostic labels and
643
+    interactive prompts.
644 644
 
645 645
     """
646 646
 
... ...
@@ -762,6 +762,27 @@ class Label(enum.Enum):
762 762
         flags="python-brace-format",
763 763
     )
764 764
     """"""
765
+    REDUCED_DERIVEPASSPHRASE_EXPORT_VAULT_02 = commented(
766
+        "",
767
+    )(
768
+        "Label :: Help text :: Explanation",
769
+        "Depending on the configuration format, "
770
+        "PATH may either be a file or a directory.  "
771
+        'We support the vault "v0.2", "v0.3" and "storeroom" formats.',
772
+    )
773
+    """"""
774
+    REDUCED_DERIVEPASSPHRASE_EXPORT_VAULT_03 = commented(
775
+        "Same PATH metavar as "
776
+        "Label.DERIVEPASSPHRASE_EXPORT_VAULT_02.",
777
+    )(
778
+        "Label :: Help text :: Explanation",
779
+        "If PATH is explicitly given as `VAULT_PATH`, "
780
+        "then use the `VAULT_PATH` environment variable to "
781
+        "determine the correct path.  "
782
+        "(Use `./VAULT_PATH` or similar to indicate a file/directory "
783
+        "actually named `VAULT_PATH`.)",
784
+    )
785
+    """"""
765 786
     DERIVEPASSPHRASE_VAULT_02 = commented(
766 787
         "The metavar is Label.VAULT_METAVAR_SERVICE.",
767 788
     )(
... ...
@@ -772,6 +793,16 @@ class Label(enum.Enum):
772 793
         flags="python-brace-format",
773 794
     )
774 795
     """"""
796
+    REDUCED_DERIVEPASSPHRASE_VAULT_02 = commented(
797
+        "Same SERVICE metavar as in "
798
+        '"Deriving a passphrase requires a SERVICE." message.',
799
+    )(
800
+        "Label :: Help text :: Explanation",
801
+        "If operating on global settings, or importing/exporting settings, "
802
+        "then SERVICE must be omitted.  "
803
+        "Otherwise it is required.",
804
+    )
805
+    """"""
775 806
     DERIVEPASSPHRASE_VAULT_EPILOG_01 = commented(
776 807
         "",
777 808
     )(
... ...
@@ -833,6 +864,13 @@ class Label(enum.Enum):
833 864
         flags="python-brace-format",
834 865
     )
835 866
     """"""
867
+    REDUCED_PASSPHRASE_GENERATION_EPILOG = commented(
868
+        "Same NUMBER metavar as --lower option.",
869
+    )(
870
+        "Label :: Help text :: Explanation",
871
+        "Use NUMBER=0 to exclude a character type from the output.",
872
+    )
873
+    """"""
836 874
     STORAGE_MANAGEMENT_EPILOG = commented(
837 875
         "The metavar is Label.STORAGE_MANAGEMENT_METAVAR_PATH.",
838 876
     )(
... ...
@@ -842,6 +880,14 @@ class Label(enum.Enum):
842 880
         flags="python-brace-format",
843 881
     )
844 882
     """"""
883
+    REDUCED_STORAGE_MANAGEMENT_EPILOG = commented(
884
+        "Same PATH metavar as --export option.",
885
+    )(
886
+        "Label :: Help text :: Explanation",
887
+        'Using "-" as PATH for standard input/standard output '
888
+        "is supported.",
889
+    )
890
+    """"""
845 891
     DEPRECATED_COMMAND_LABEL = commented(
846 892
         "We use this format string to indicate, at the beginning "
847 893
         "of a command's help text, that this command is deprecated.",
... ...
@@ -1969,6 +2015,17 @@ class WarnMsgTemplate(enum.Enum):
1969 2015
         flags="python-brace-format",
1970 2016
     )
1971 2017
     """"""
2018
+    REDUCED_EMPTY_SERVICE_NOT_SUPPORTED = commented(
2019
+        "Same SERVICE metavar as in "
2020
+        '"Deriving a passphrase requires a SERVICE." message.',
2021
+    )(
2022
+        "Warning message",
2023
+        "An empty SERVICE is not supported by vault(1).  "
2024
+        "For compatibility, this will be treated as if "
2025
+        "SERVICE was not supplied, i.e., it will error out, "
2026
+        "or operate on global settings.",
2027
+    )
2028
+    """"""
1972 2029
     EMPTY_SERVICE_SETTINGS_INACCESSIBLE = commented(
1973 2030
         "",
1974 2031
     )(
... ...
@@ -1981,6 +2038,19 @@ class WarnMsgTemplate(enum.Enum):
1981 2038
         flags="python-brace-format",
1982 2039
     )
1983 2040
     """"""
2041
+    REDUCED_EMPTY_SERVICE_SETTINGS_INACCESSIBLE = commented(
2042
+        "Same SERVICE metavar as in "
2043
+        '"Deriving a passphrase requires a SERVICE." message.',
2044
+    )(
2045
+        "Warning message",
2046
+        "An empty SERVICE is not supported by vault(1).  "
2047
+        "The empty-string service settings will be inaccessible "
2048
+        "and ineffective.  "
2049
+        "To ensure that vault(1) and {PROG_NAME} see the settings, "  # noqa: RUF027
2050
+        'move them into the "global" section.',
2051
+        flags="python-brace-format",
2052
+    )
2053
+    """"""
1984 2054
     FAILED_TO_MIGRATE_CONFIG = commented(
1985 2055
         '"error" is supplied by the operating system (errno/strerror).',
1986 2056
     )(
... ...
@@ -2352,6 +2422,16 @@ class ErrMsgTemplate(enum.Enum):
2352 2422
         flags="python-brace-format",
2353 2423
     )
2354 2424
     """"""
2425
+    REDUCED_PARAMS_NEEDS_SERVICE = commented(
2426
+        "The param is a long-form command-line option name.  "
2427
+        "Same SERVICE metavar as in "
2428
+        '"Deriving a passphrase requires a SERVICE." message.',
2429
+    )(
2430
+        "Error message",
2431
+        "{param} requires a SERVICE.",
2432
+        flags="python-brace-format",
2433
+    )
2434
+    """"""
2355 2435
     PARAMS_NEEDS_SERVICE_OR_CONFIG = commented(
2356 2436
         "The param is a long-form command-line option name, "
2357 2437
         "the metavar is Label.VAULT_METAVAR_SERVICE.",
... ...
@@ -2361,6 +2441,16 @@ class ErrMsgTemplate(enum.Enum):
2361 2441
         flags="python-brace-format",
2362 2442
     )
2363 2443
     """"""
2444
+    REDUCED_PARAMS_NEEDS_SERVICE_OR_CONFIG = commented(
2445
+        "The param is a long-form command-line option name.  "
2446
+        "Same SERVICE metavar as in "
2447
+        '"Deriving a passphrase requires a SERVICE." message.',
2448
+    )(
2449
+        "Error message",
2450
+        "{param} requires a SERVICE or --config.",
2451
+        flags="python-brace-format",
2452
+    )
2453
+    """"""
2364 2454
     PARAMS_NO_SERVICE = commented(
2365 2455
         "The param is a long-form command-line option name, "
2366 2456
         "the metavar is Label.VAULT_METAVAR_SERVICE.",
... ...
@@ -2370,6 +2460,16 @@ class ErrMsgTemplate(enum.Enum):
2370 2460
         flags="python-brace-format",
2371 2461
     )
2372 2462
     """"""
2463
+    REDUCED_PARAMS_NO_SERVICE = commented(
2464
+        "The param is a long-form command-line option name.  "
2465
+        "Same SERVICE metavar as in "
2466
+        '"Deriving a passphrase requires a SERVICE." message.',
2467
+    )(
2468
+        "Error message",
2469
+        "{param} does not take a SERVICE argument.",
2470
+        flags="python-brace-format",
2471
+    )
2472
+    """"""
2373 2473
     SERVICE_REQUIRED = commented(
2374 2474
         "The metavar is Label.VAULT_METAVAR_SERVICE.",
2375 2475
     )(
... ...
@@ -2378,6 +2478,13 @@ class ErrMsgTemplate(enum.Enum):
2378 2478
         flags="python-brace-format",
2379 2479
     )
2380 2480
     """"""
2481
+    REDUCED_SERVICE_REQUIRED = commented(
2482
+        "",
2483
+    )(
2484
+        "Error message",
2485
+        "Deriving a passphrase requires a SERVICE.",
2486
+    )
2487
+    """"""
2381 2488
     SET_AND_UNSET_SAME_SETTING = commented(
2382 2489
         "The rephrasing "
2383 2490
         '"Attempted to unset and set the same setting '
2384 2491