contrib: override system locale in gen-manpages.py #34916

pull Sjors wants to merge 1 commits into bitcoin:master from Sjors:2026/03/manpages-locale changing 1 files +19 −5
  1. Sjors commented at 9:48 am on March 25, 2026: member

    bitcoin-qt --help emits a translation of “version”, which creates a diff when updating or verifying man pages.

    The script aborts earlier however, because bitcoin-qt --version also emits a localized output, which triggers the Copyright (C) assertion on a translated term like “Auteursrecht”.

    Fix this by passing --lang=en to both bitcoin-qt invocations.

    None of the actual command options are translated, so this commit does not affect the actual manual page.

    Noticed while verifying the manual updates in #34800 on macOS with Dutch system locale.

    See also https://github.com/bitcoin/bitcoin/blob/master/test/lint/lint-locale-dependence.py notes about localization (though the issue here is translation).

  2. contrib: override system locale in gen-manpages.py
    bitcoin-qt --help emits a translation of "version", which creates
    a diff when updating or verifying man pages.
    
    The script aborts earlier however, because bitcoin-qt --version also
    emits a localized output, which triggers the "Copyright (C)" assertion
    on a translated term like "Auteursrecht".
    
    Fix this by passing --lang=en to both bitcoin-qt invocations.
    
    None of the actual command options are translated, so this
    commit does not affect the actual manual page.
    758f208cc1
  3. DrahtBot added the label Scripts and tools on Mar 25, 2026
  4. DrahtBot commented at 9:49 am on March 25, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  5. Sjors commented at 9:49 am on March 25, 2026: member
    An alternative approach could be to just stop translating these terms, but that might impact the GUI.
  6. in contrib/devtools/gen-manpages.py:58 in 758f208cc1
    54+    is_qt = relpath == "bin/bitcoin-qt"
    55     try:
    56-        r = subprocess.run([abspath, "--version"], stdout=subprocess.PIPE, check=True, text=True)
    57+        cmd_args = ["--version"]
    58+        if is_qt:
    59+            cmd_args.append("--lang=en")
    


    maflcko commented at 9:59 am on March 25, 2026:
    Seems a lot of code when you could just set LC_ALL=en_US.UTF-8 ?

    Sjors commented at 10:09 am on March 25, 2026:
    0LC_ALL=en_US.UTF-8 BUILDDIR=build_genman ./contrib/devtools/gen-manpages.py
    1Traceback (most recent call last):
    2  File "/Users/dev/bitcoin-pr/34800-backports/./contrib/devtools/gen-manpages.py", line 70, in <module>
    3    assert copyright[0].startswith('Copyright (C)')
    4AssertionError
    

    Maybe the script could set it though, I’ll look into that.


    maflcko commented at 10:22 am on March 25, 2026:

    AssertionError

    Not sure why this fails. The script does not hide the outer env, so it should be passed down all prcoesses, no? Maybe I am missing something obvious?


    Sjors commented at 10:23 am on March 25, 2026:
    Just setting --lang=en is simple enough I think. I’d rather not take a crash course on which locales are guaranteed to be available on which system. Though it seems even Windows has caught up: https://stackoverflow.com/a/79865313

    Sjors commented at 10:27 am on March 25, 2026:

    Not sure why this fails.

    I suspect it’s because QLocale::system().name() ignores it. That might also explain why bitcoind doesn’t have this issue.


    maflcko commented at 10:35 am on March 25, 2026:

    Not sure why Windows would be relevant to mention here. It is not supported by this script, before or even after the changes here.

    Setting LC_ALL works locally for me:

    0$ LC_ALL=nl_NL.UTF-8 ./bld-cmake/bin/bitcoin-qt -version 
    1Bitcoin Core versie v31.99.0-1904e78e0041
    2Auteursrecht (C) 2009-2026 De Bitcoin Core ontwikkelaars
    

    So it should be possible to find the one setting it to English, no?


    Sjors commented at 1:02 pm on March 25, 2026:
    0LC_ALL=en_US.UTF-8 ./build_genman/bin/bitcoin-qt -version
    1Bitcoin Core versie v31.0.0rc2
    2Auteursrecht (C) 2009-2026 De Bitcoin Core ontwikkelaars
    3
    4Gelieve bij te dragen als je Bitcoin Core nuttig vindt. Bezoek
    

    macOS 26.3.1


    maflcko commented at 1:32 pm on March 25, 2026:

    Ok, so this only about macOS. Could put macOS in the title?

    Another try, but probably won’t work for the same reason:

    0$ LANGUAGE=nl ./bld-cmake/bin/bitcoin-qt -version 
    1Bitcoin Core versie v31.99.0-fabbfec3b00c
    2Auteursrecht (C) 2009-2026 De Bitcoin Core ontwikkelaars
    

    maflcko commented at 1:35 pm on March 25, 2026:
    Also, I don’t think https://github.com/bitcoin/bitcoin/blob/master/test/lint/lint-locale-dependence.py#L6-L8 is relevant. This is about locale-dependent posix functions being called. However, the topic of this pull request is about translations of translatable strings. (bitcoind has the translation function set to the nullptr, if this is what you wanted to refer to instead.)

    Sjors commented at 1:55 pm on March 25, 2026:

    Ok, so this only about macOS.

    I haven’t tried every unix flavor, might be a BSD thing?

    In any case, even if your workaround works on other platforms, that doesn’t mean the problem is macOS-only. It’s just that those platforms could use a more compact fix instead. Unless you actually can’t reproduce the original issue on Linux?

    Another try, but probably won’t work for the same reason

    Indeed doesn’t work, ignores other languages.


    Sjors commented at 1:57 pm on March 25, 2026:

    This is about locale-dependent

    Updated the comment to make it clear this isn’t localization but translation.

  7. DrahtBot added the label CI failed on Mar 25, 2026
  8. maflcko added the label macOS on Mar 25, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-03-30 00:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me