Recent commits to derivepassphrase.git (220d71df817f2662308efab15e98f138fd6dde18) https://git.schokokeks.org/derivepassphrase.git/tree/220d71df817f2662308efab15e98f138fd6dde18 Recent commits feed provided by GitList. Fix coverage Exclude further machinery from coverage that isn't meant to be tested. https://git.schokokeks.org/derivepassphrase.git/commit/220d71df817f2662308efab15e98f138fd6dde18 software@the13thletter.info (Marco Ricci) Tue, 31 Dec 2024 23:58:59 +0100 220d71df817f2662308efab15e98f138fd6dde18 Reimplement `--help` and `--version` options in a translatable way Reimplement the machinery for displaying help texts and version information, supporting translatable strings. Besides the one-line help texts for the `--help` and `--version` options, the version information text is a translatable string itself, in case the name and version number should be rearranged, or prefixed or suffixed, or whatever. https://git.schokokeks.org/derivepassphrase.git/commit/f6e66845b1b4c889aae2f7833678eed2e49c5ae6 software@the13thletter.info (Marco Ricci) Tue, 31 Dec 2024 22:30:36 +0100 f6e66845b1b4c889aae2f7833678eed2e49c5ae6 Replace strings in `derivepassphrase export vault` with translatable ones Apparently, we overlooked this in 59d73c8320650a6bcb77eed759c694949d350cdb. https://git.schokokeks.org/derivepassphrase.git/commit/b225fb3b9cf104a042d810a2b82cd484cc7d5f33 software@the13thletter.info (Marco Ricci) Tue, 31 Dec 2024 22:18:29 +0100 b225fb3b9cf104a042d810a2b82cd484cc7d5f33 Force logging calls in error callback to be uninterpolated Remove the `args` argument to the error callback and to the underlying `logging` function, forcing logger to skip log message interpolation in any case. https://git.schokokeks.org/derivepassphrase.git/commit/0e31ed481bf84684233c909ae8f559c360386fb1 software@the13thletter.info (Marco Ricci) Tue, 31 Dec 2024 22:08:02 +0100 0e31ed481bf84684233c909ae8f559c360386fb1 Provide a function to reload translations for derivepassphrase https://git.schokokeks.org/derivepassphrase.git/commit/73f1128336d79d6f1ee0d8d783d58d6c6d629cc3 software@the13thletter.info (Marco Ricci) Tue, 31 Dec 2024 18:40:01 +0100 73f1128336d79d6f1ee0d8d783d58d6c6d629cc3 Add a writer function for derivepassphrase's .po template To be used together with the gettext toolset. Many things are hard-coded. https://git.schokokeks.org/derivepassphrase.git/commit/357468984efebf66365a5dfac75010d7120e42ce software@the13thletter.info (Marco Ricci) Tue, 31 Dec 2024 16:03:01 +0100 357468984efebf66365a5dfac75010d7120e42ce Fix some translation typos and inconsistent translation comments https://git.schokokeks.org/derivepassphrase.git/commit/dc3b7bab8ee8b59e7a1d60315b59e296dce51f2e software@the13thletter.info (Marco Ricci) Tue, 31 Dec 2024 16:03:01 +0100 dc3b7bab8ee8b59e7a1d60315b59e296dce51f2e Update the CLI to use the translatable strings We implement the translations in a deferred manner, via objects that stringify to their correct translation. Since `click` 8.1, help texts are (mostly) stored first and processed only when the help page is emitted. Accordingly, this system can be adapted to support our translatable strings: we need only ensure the help text is stringified just before it is formatted and emitted. This in turn can be achieved by reimplementing the help page assembly and formatting in a custom `click.Command` class, as has already been done to implement help/option group support. Once this is in place, it remains to exchange all inline help texts with the corresponding translatable string, and adapt the tests to the new messages. While most of the changes are straightforward, some subtleties remain. First, the help texts are now supplied as (separately translatable) paragraphs to the `click.command` decorator, instead of being extracted from the respective function docstring. The docstrings in return have been shortened down. Second, since the new capabilities are implemented via custom `click.Command`, `click.MultiCommand` and `click.Option` subclasses, every option and command must derive from one of these classes. This necessitates the creation of an empty `StandardOption` class for options without an option group, and making `_DefaultToVaultGroup` a subclass of `CommandWithHelpGroups`. Third, since the `click.Option` class actually processes its help text eagerly, the subclass must hide the (non-string) help text from the `click.Option` constructor and later restore it. Finally, while the tests currently pass as before, they now implicitly rely on *not* loading any translations. Furthermore, there is no mechanism in place with which to isolate the translation system from the user's environment for testing purposes, nor is there a (controlled) mechanism to test `derivepassphrase` under a different language. Once there are actual translations, future commits will need to establish such a missing mechanism for translation loading/switching/forcing. https://git.schokokeks.org/derivepassphrase.git/commit/59d73c8320650a6bcb77eed759c694949d350cdb software@the13thletter.info (Marco Ricci) Mon, 30 Dec 2024 23:45:01 +0100 59d73c8320650a6bcb77eed759c694949d350cdb Add more translatable strings and serialization machinery Add all help texts and metavars as translatable strings. Furthermore, add extra machinery for introspection to the serialized translatable strings class, which will make debugging values in pytest much easier. Add another couple of error messages (and update the manpages as well) for low-level errors while querying the SSH agent for the key list or while requesting a signature. (Previously, we forwarded the internal English exception message directly.) Update the manpage to include these as well. https://git.schokokeks.org/derivepassphrase.git/commit/df1756fe1222e9bf01b9f256a8a212174c144876 software@the13thletter.info (Marco Ricci) Mon, 30 Dec 2024 21:34:42 +0100 df1756fe1222e9bf01b9f256a8a212174c144876 Extract translatable log messages into separate module Extract all log messages into a separate module, so that they may be translated in a future version. We anticipate the use of such a message in a `logging` call, so we provide a wrapper object that defers the string interpolation until its serialization is called, and caches the result. (This is all as per the recommendation from the standard `logging` module.) Implemented this way, it is easy to run easy transformations on the specific log message template, e.g. substituting a translated message template, or trimming the filename placeholder if the filename is `None`. As an added benefit, this organization also makes it somewhat easy to ensure message consistency across different use sites and to generate diagnostics lists for inclusion in the manpage. While we intend to use the gettext toolset to implement the translation later, we do *not* currently use the standard `_` gettext alias or otherwise mark up the strings in an `xgettext`-compatible manner. Both the GNU version of `xgettext` and the Python work-alike `xgettext.py` suck: the GNU version does not completely understand Python syntax and cannot sensibly parse `black`-/`ruff`-formatted code using implicit string concatenation or trailing commas in function argument lists, and `xgettext.py` is so outdated (even in current Pythons) that it does not support `xgettext`'s `--add-comment` option for extracting extra comments for the translators. So instead of attempting to cram the strings and comments into some formatter-resistant and `xgettext`-compatible shape (a very futile endeavor so far), store enough information that we could generate the `.po` files ourselves with very little additional effort. https://git.schokokeks.org/derivepassphrase.git/commit/317489552ba4585e773775417b4d3f106538f98b software@the13thletter.info (Marco Ricci) Wed, 25 Dec 2024 21:41:22 +0100 317489552ba4585e773775417b4d3f106538f98b