Fix miscellaneous issues with the CLI messages
Marco Ricci

Marco Ricci commited on 2025-03-16 23:13:47
Zeige 4 geänderte Dateien mit 60 Einfügungen und 36 Löschungen.


  * The "interactive input" replacement value for the
    `WarnMsgTemplate.PASSPHRASE_NOT_NORMALIZED` message is now
    translatable.  The previous form was quirky and too clever, and
    probably only worked in languages with similar grammar and sentence
    structure.

  * The `Label.DERIVEPASSPHRASE_VAULT_REPEAT_HELP_TEXT` message was
    wrong due to an off-by-one error.

  * The `Label.DERIVEPASSPHRASE_VAULT_PRINT_NOTES_BEFORE_HELP_TEXT`
    message should reference the service metavar, not the term "service"
    itself.

  * The default notes placeholder text when using the vault legacy
    editor interface is very wordy, and incited at least one test user
    to delete it character by character before entering the new notes.
    A shorter placeholder text will hopefully achieve the same effect in
    less keystrokes.

  * Several verb tense and punctuation mistakes were corrected.
... ...
@@ -7,8 +7,8 @@ msgid ""
7 7
 msgstr ""
8 8
 "Project-Id-Version: derivepassphrase 0.5a1.dev1\n"
9 9
 "Report-Msgid-Bugs-To: software@the13thletter.info\n"
10
-"POT-Creation-Date: 2025-03-16 13:30+0100\n"
11
-"PO-Revision-Date: 2025-03-16 13:30+0100\n"
10
+"POT-Creation-Date: 2025-03-16 23:12+0100\n"
11
+"PO-Revision-Date: 2025-03-16 23:12+0100\n"
12 12
 "Last-Translator: AUTHOR <someone@example.com>\n"
13 13
 "Language: en\n"
14 14
 "Language-Team: English\n"
... ...
@@ -45,6 +45,13 @@ msgctxt "Label :: Error message :: Metavar"
45 45
 msgid "service-specific settings"
46 46
 msgstr ""
47 47
 
48
+#. TRANSLATORS: This value is used as the {key} metavar for Label.PASSPHRASE_NOT_NORMALIZED if the passphrase was entered interactively.
49
+#. 
50
+#. Message-ID: Label.SETTINGS_ORIGIN_INTERACTIVE
51
+msgctxt "Label :: Error message :: Metavar"
52
+msgid "interactive input"
53
+msgstr ""
54
+
48 55
 #. TRANSLATORS: Message-ID: Label.CONFIGURATION_EPILOG
49 56
 msgctxt "Label :: Help text :: Explanation"
50 57
 msgid "Use $VISUAL or $EDITOR to configure the spawned editor."
... ...
@@ -122,7 +129,7 @@ msgstr ""
122 129
 #. 
123 130
 #. Message-ID: Label.DERIVEPASSPHRASE_VAULT_NOTES_LEGACY_INSTRUCTION_TEXT
124 131
 msgctxt "Label :: Help text :: Explanation"
125
-msgid "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
132
+msgid "INSERT NOTES HERE"
126 133
 msgstr ""
127 134
 
128 135
 #. TRANSLATORS: The metavar is Label.PASSPHRASE_GENERATION_METAVAR_NUMBER.
... ...
@@ -347,8 +354,9 @@ msgstr ""
347 354
 #. TRANSLATORS: The corresponding option is displayed as "--print-notes-before / --print-notes-after", so you may want to hint that the default (after) is the second of those options.
348 355
 #. 
349 356
 #. Message-ID: Label.DERIVEPASSPHRASE_VAULT_PRINT_NOTES_BEFORE_HELP_TEXT
357
+#, python-brace-format
350 358
 msgctxt "Label :: Help text :: One-line description"
351
-msgid "Print the service notes (if any) before or after (default) the existing configuration."
359
+msgid "Print the notes for {service_metavar} (if any) before or after (default) the derived passphrase."
352 360
 msgstr ""
353 361
 
354 362
 #. TRANSLATORS: The metavar is Label.PASSPHRASE_GENERATION_METAVAR_NUMBER.
... ...
@@ -356,7 +364,7 @@ msgstr ""
356 364
 #. Message-ID: Label.DERIVEPASSPHRASE_VAULT_REPEAT_HELP_TEXT
357 365
 #, python-brace-format
358 366
 msgctxt "Label :: Help text :: One-line description"
359
-msgid "Forbid any run of {metavar} identical characters."
367
+msgid "Restrict runs of identical characters to at most {metavar} characters."
360 368
 msgstr ""
361 369
 
362 370
 #. TRANSLATORS: The metavar is Label.PASSPHRASE_GENERATION_METAVAR_NUMBER.
... ...
@@ -379,7 +387,7 @@ msgstr ""
379 387
 #. 
380 388
 #. Message-ID: Label.DERIVEPASSPHRASE_VAULT_UNSET_HELP_TEXT
381 389
 msgctxt "Label :: Help text :: One-line description"
382
-msgid "With --config, also unsets the given setting.  May be specified multiple times."
390
+msgid "With --config, also unset the given setting.  May be specified multiple times."
383 391
 msgstr ""
384 392
 
385 393
 #. TRANSLATORS: The metavar is Label.PASSPHRASE_GENERATION_METAVAR_NUMBER.
... ...
@@ -757,7 +765,7 @@ msgctxt "Debug message"
757 765
 msgid "Buffer: {contents}\n"
758 766
 "\n"
759 767
 "IV: {iv}\n"
760
-"Payload: {payload}\n"
768
+"Payload (ciphertext): {payload}\n"
761 769
 "MAC: {mac}"
762 770
 msgstr ""
763 771
 
... ...
@@ -794,7 +802,7 @@ msgstr ""
794 802
 #. 
795 803
 #. Message-ID: InfoMsgTemplate.ASSEMBLING_CONFIG_STRUCTURE
796 804
 msgctxt "Info message"
797
-msgid "Assembling config structure"
805
+msgid "Assembling config structure."
798 806
 msgstr ""
799 807
 
800 808
 #. TRANSLATORS: "fmt" is a string such as "v0.2" or "storeroom", indicating the format which we tried to load the vault configuration as.
... ...
@@ -809,7 +817,7 @@ msgstr ""
809 817
 #. 
810 818
 #. Message-ID: InfoMsgTemplate.CHECKING_CONFIG_STRUCTURE_CONSISTENCY
811 819
 msgctxt "Info message"
812
-msgid "Checking config structure consistency"
820
+msgid "Checking config structure consistency."
813 821
 msgstr ""
814 822
 
815 823
 #. TRANSLATORS: This message is emitted by the vault configuration exporter for "storeroom"-type configuration directories.  The system stores entries in different "buckets" of a hash table.  We parse the directory bucket by bucket.  All buckets are numbered in hexadecimal, and typically there are 32 buckets, so 2-digit hex numbers.
... ...
@@ -817,14 +825,14 @@ msgstr ""
817 825
 #. Message-ID: InfoMsgTemplate.DECRYPTING_BUCKET
818 826
 #, python-brace-format
819 827
 msgctxt "Info message"
820
-msgid "Decrypting bucket {bucket_number}"
828
+msgid "Decrypting bucket {bucket_number}."
821 829
 msgstr ""
822 830
 
823 831
 #. TRANSLATORS: This message is emitted by the vault configuration exporter for "storeroom"-type configuration directories.  `.keys` is a filename, from which data about the master keys for this configuration are loaded.
824 832
 #. 
825 833
 #. Message-ID: InfoMsgTemplate.PARSING_MASTER_KEYS_DATA
826 834
 msgctxt "Info message"
827
-msgid "Parsing master keys data from .keys"
835
+msgid "Parsing master keys data from `.keys`."
828 836
 msgstr ""
829 837
 
830 838
 #. TRANSLATORS: This message immediately follows an error message about a missing library that needs to be installed.  The Python Package Index (PyPI) supports declaring sets of optional dependencies as "extras", so users installing from PyPI can request reinstallation with a named "extra" being enabled.  This would then let the installer take care of the missing libraries automatically, hence this suggestion to PyPI users.
... ...
@@ -845,24 +853,24 @@ msgstr ""
845 853
 
846 854
 #. TRANSLATORS: Message-ID: InfoMsgTemplate.VAULT_NATIVE_CHECKING_MAC
847 855
 msgctxt "Info message"
848
-msgid "Checking MAC"
856
+msgid "Checking MAC."
849 857
 msgstr ""
850 858
 
851 859
 #. TRANSLATORS: Message-ID: InfoMsgTemplate.VAULT_NATIVE_DECRYPTING_CONTENTS
852 860
 msgctxt "Info message"
853
-msgid "Decrypting contents"
861
+msgid "Decrypting contents."
854 862
 msgstr ""
855 863
 
856 864
 #. TRANSLATORS: Message-ID: InfoMsgTemplate.VAULT_NATIVE_DERIVING_KEYS
857 865
 msgctxt "Info message"
858
-msgid "Deriving an encryption and signing key"
866
+msgid "Deriving an encryption and signing key."
859 867
 msgstr ""
860 868
 
861 869
 #. TRANSLATORS: This message is emitted by the vault configuration exporter for "native"-type configuration directories.  "IV" means "initialization vector", and "MAC" means "message authentication code".  They are specifically cryptographic terms, as is "payload".  The acronyms "IV" and "MAC" are assumed to be well-known to the English target audience, or at least discoverable by them; they *are* asking for debug output, after all.  Please use your judgement as to whether to translate these terms or not, expanded or not.
862 870
 #. 
863 871
 #. Message-ID: InfoMsgTemplate.VAULT_NATIVE_PARSING_IV_PAYLOAD_MAC
864 872
 msgctxt "Info message"
865
-msgid "Parsing IV, payload and MAC from the file contents"
873
+msgid "Parsing IV, payload and MAC from the file contents."
866 874
 msgstr ""
867 875
 
868 876
 #. TRANSLATORS: Message-ID: WarnMsgTemplate.EDITING_NOTES_BUT_NOT_STORING_CONFIG
... ...
@@ -909,7 +917,7 @@ msgctxt "Warning message"
909 917
 msgid "A backup copy of the old notes was saved to {filename!r}.  This is a safeguard against editing mistakes, because the vault(1)-compatible legacy editor interface does not allow aborting mid-edit, and because the notes were actually changed."
910 918
 msgstr ""
911 919
 
912
-#. TRANSLATORS: The key is a (vault) configuration key, in JSONPath syntax, typically "$.global" for the global passphrase or "$.services.service_name" or "$.services["service with spaces"]" for the services "service_name" and "service with spaces", respectively.  The form is one of the four Unicode normalization forms: NFC, NFD, NFKC, NFKD.  The asterisks are not special.  Please feel free to substitute any other appropriate way to mark up emphasis of the word "displays".
920
+#. TRANSLATORS: The key is a (vault) configuration key, in JSONPath syntax, typically "$.global" for the global passphrase or "$.services.service_name" or "$.services["service with spaces"]" for the services "service_name" and "service with spaces", respectively.  Alternatively, it may be the value of Label.SETTINGS_ORIGIN_INTERACTIVE if the passphrase was entered interactively.  The form is one of the four Unicode normalization forms: NFC, NFD, NFKC, NFKD.  The asterisks are not special.  Please feel free to substitute any other appropriate way to mark up emphasis of the word "displays".
913 921
 #. 
914 922
 #. Message-ID: WarnMsgTemplate.PASSPHRASE_NOT_NORMALIZED
915 923
 #, python-brace-format
... ...
@@ -705,11 +705,11 @@ class ORIGIN(enum.Enum):
705 705
     """The origin of a setting, if not from the user configuration file.
706 706
 
707 707
     Attributes:
708
-        INTERACTIVE (str): interactive input
708
+        INTERACTIVE (_msg.Label): interactive input
709 709
 
710 710
     """
711 711
 
712
-    INTERACTIVE = 'interactive input'
712
+    INTERACTIVE = _msg.Label.SETTINGS_ORIGIN_INTERACTIVE
713 713
     """"""
714 714
 
715 715
 
... ...
@@ -765,7 +765,9 @@ def check_for_misleading_passphrase(
765 765
         raise AssertionError(msg)
766 766
     logger = logging.getLogger(PROG_NAME)
767 767
     formatted_key = (
768
-        key.value if isinstance(key, ORIGIN) else _types.json_path(key)
768
+        str(_msg.TranslatedString(key.value))
769
+        if isinstance(key, ORIGIN)
770
+        else _types.json_path(key)
769 771
     )
770 772
     if 'phrase' in value:
771 773
         phrase = value['phrase']
... ...
@@ -679,6 +679,14 @@ class Label(enum.Enum):
679 679
         'service-specific settings',
680 680
     )
681 681
     """"""
682
+    SETTINGS_ORIGIN_INTERACTIVE = commented(
683
+        'This value is used as the {key} metavar for '
684
+        'Label.PASSPHRASE_NOT_NORMALIZED if the passphrase was '
685
+        'entered interactively.',
686
+    )(
687
+        'Label :: Error message :: Metavar',
688
+        'interactive input',
689
+    )
682 690
     CONFIGURATION_EPILOG = commented(
683 691
         '',
684 692
     )(
... ...
@@ -808,9 +816,7 @@ class Label(enum.Enum):
808 816
         'obviously recognize as placeholder text.)'
809 817
     )(
810 818
         'Label :: Help text :: Explanation',
811
-        'Lorem ipsum dolor sit amet, consectetur adipiscing elit, '
812
-        'sed do eiusmod tempor incididunt ut labore '
813
-        'et dolore magna aliqua.',
819
+        'INSERT NOTES HERE',
814 820
     )
815 821
     """"""
816 822
     PASSPHRASE_GENERATION_EPILOG = commented(
... ...
@@ -1101,15 +1107,17 @@ class Label(enum.Enum):
1101 1107
         'hint that the default (after) is the second of those options.',
1102 1108
     )(
1103 1109
         'Label :: Help text :: One-line description',
1104
-        'Print the service notes (if any) before or after (default) '
1105
-        'the existing configuration.',
1110
+        'Print the notes for {service_metavar} (if any) before or '
1111
+        'after (default) the derived passphrase.',
1112
+        flags='python-brace-format',
1106 1113
     )
1107 1114
     """"""
1108 1115
     DERIVEPASSPHRASE_VAULT_REPEAT_HELP_TEXT = commented(
1109 1116
         'The metavar is Label.PASSPHRASE_GENERATION_METAVAR_NUMBER.',
1110 1117
     )(
1111 1118
         'Label :: Help text :: One-line description',
1112
-        'Forbid any run of {metavar} identical characters.',
1119
+        'Restrict runs of identical characters to at most {metavar} '
1120
+        'characters.',
1113 1121
         flags='python-brace-format',
1114 1122
     )
1115 1123
     """"""
... ...
@@ -1138,7 +1146,7 @@ class Label(enum.Enum):
1138 1146
         '"--config" for this option to have any effect.',
1139 1147
     )(
1140 1148
         'Label :: Help text :: One-line description',
1141
-        'With --config, also unsets the given setting.  '
1149
+        'With --config, also unset the given setting.  '
1142 1150
         'May be specified multiple times.',
1143 1151
     )
1144 1152
     """"""
... ...
@@ -1709,7 +1717,7 @@ Buffer: {contents}
1709 1717
 
1710 1718
   \b
1711 1719
   IV: {iv}
1712
-  Payload: {payload}
1720
+  Payload (ciphertext): {payload}
1713 1721
   MAC: {mac}
1714 1722
 """,
1715 1723
         flags='python-brace-format',
... ...
@@ -1775,7 +1783,7 @@ class InfoMsgTemplate(enum.Enum):
1775 1783
         'build it on-the-fly), hence the term "assembling".',
1776 1784
     )(
1777 1785
         'Info message',
1778
-        'Assembling config structure',
1786
+        'Assembling config structure.',
1779 1787
     )
1780 1788
     """"""
1781 1789
     CANNOT_LOAD_AS_VAULT_CONFIG = commented(
... ...
@@ -1796,7 +1804,7 @@ class InfoMsgTemplate(enum.Enum):
1796 1804
         'assembled structure is internally consistent.',
1797 1805
     )(
1798 1806
         'Info message',
1799
-        'Checking config structure consistency',
1807
+        'Checking config structure consistency.',
1800 1808
     )
1801 1809
     """"""
1802 1810
     DECRYPTING_BUCKET = commented(
... ...
@@ -1808,7 +1816,7 @@ class InfoMsgTemplate(enum.Enum):
1808 1816
         '32 buckets, so 2-digit hex numbers.',
1809 1817
     )(
1810 1818
         'Info message',
1811
-        'Decrypting bucket {bucket_number}',
1819
+        'Decrypting bucket {bucket_number}.',
1812 1820
         flags='python-brace-format',
1813 1821
     )
1814 1822
     """"""
... ...
@@ -1819,7 +1827,7 @@ class InfoMsgTemplate(enum.Enum):
1819 1827
         'for this configuration are loaded.',
1820 1828
     )(
1821 1829
         'Info message',
1822
-        'Parsing master keys data from .keys',
1830
+        'Parsing master keys data from `.keys`.',
1823 1831
     )
1824 1832
     """"""
1825 1833
     PIP_INSTALL_EXTRA = commented(
... ...
@@ -1850,21 +1858,21 @@ class InfoMsgTemplate(enum.Enum):
1850 1858
         '',
1851 1859
     )(
1852 1860
         'Info message',
1853
-        'Checking MAC',
1861
+        'Checking MAC.',
1854 1862
     )
1855 1863
     """"""
1856 1864
     VAULT_NATIVE_DECRYPTING_CONTENTS = commented(
1857 1865
         '',
1858 1866
     )(
1859 1867
         'Info message',
1860
-        'Decrypting contents',
1868
+        'Decrypting contents.',
1861 1869
     )
1862 1870
     """"""
1863 1871
     VAULT_NATIVE_DERIVING_KEYS = commented(
1864 1872
         '',
1865 1873
     )(
1866 1874
         'Info message',
1867
-        'Deriving an encryption and signing key',
1875
+        'Deriving an encryption and signing key.',
1868 1876
     )
1869 1877
     """"""
1870 1878
     VAULT_NATIVE_PARSING_IV_PAYLOAD_MAC = commented(
... ...
@@ -1880,7 +1888,7 @@ class InfoMsgTemplate(enum.Enum):
1880 1888
         'or not, expanded or not.',
1881 1889
     )(
1882 1890
         'Info message',
1883
-        'Parsing IV, payload and MAC from the file contents',
1891
+        'Parsing IV, payload and MAC from the file contents.',
1884 1892
     )
1885 1893
     """"""
1886 1894
 
... ...
@@ -1950,6 +1958,9 @@ class WarnMsgTemplate(enum.Enum):
1950 1958
         '"$.services.service_name" or "$.services["service with spaces"]" '
1951 1959
         'for the services "service_name" and "service with spaces", '
1952 1960
         'respectively.  '
1961
+        'Alternatively, it may be the value of '
1962
+        'Label.SETTINGS_ORIGIN_INTERACTIVE if the passphrase was '
1963
+        'entered interactively.  '
1953 1964
         'The form is one of the four Unicode normalization forms: '
1954 1965
         'NFC, NFD, NFKC, NFKD.  '
1955 1966
         'The asterisks are not special.  '
... ...
@@ -1746,7 +1746,10 @@ class _VaultContext:  # noqa: PLR0904
1746 1746
     'print_notes_before',
1747 1747
     default=False,
1748 1748
     help=_msg.TranslatedString(
1749
-        _msg.Label.DERIVEPASSPHRASE_VAULT_PRINT_NOTES_BEFORE_HELP_TEXT
1749
+        _msg.Label.DERIVEPASSPHRASE_VAULT_PRINT_NOTES_BEFORE_HELP_TEXT,
1750
+        service_metavar=_msg.TranslatedString(
1751
+            _msg.Label.VAULT_METAVAR_SERVICE
1752
+        ),
1750 1753
     ),
1751 1754
     cls=cli_machinery.CompatibilityOption,
1752 1755
 )
1753 1756