From faff8403f0aac3b5ec26d3c7fc98240f879f9906 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 9 Oct 2024 11:48:14 +0200 Subject: [PATCH] refactor: Pick translated string after format This passes the return value of _() directly to strprintf so the format string can be checked at compile time in a future commit. --- src/clientversion.cpp | 12 +++++++----- test/lint/run-lint-format-strings.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 6fa3c700ee7..af58c3023f5 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -71,7 +71,7 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::string CopyrightHolders(const std::string& strPrefix) { - const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION); + const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION).translated; std::string strCopyrightHolders = strPrefix + copyright_devs; // Make sure Bitcoin Core copyright is not removed by accident @@ -85,15 +85,17 @@ std::string LicenseInfo() { const std::string URL_SOURCE_CODE = ""; - return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" + + return CopyrightHolders(strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR).translated + " ") + "\n" + "\n" + strprintf(_("Please contribute if you find %s useful. " - "Visit %s for further information about the software.").translated, CLIENT_NAME, "<" CLIENT_URL ">") + + "Visit %s for further information about the software."), + CLIENT_NAME, "<" CLIENT_URL ">") + .translated + "\n" + - strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) + + strprintf(_("The source code is available from %s."), URL_SOURCE_CODE).translated + "\n" + "\n" + _("This is experimental software.").translated + "\n" + - strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "") + + strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "").translated + "\n"; } diff --git a/test/lint/run-lint-format-strings.py b/test/lint/run-lint-format-strings.py index d3c0ac92e5d..4402ec2d57f 100755 --- a/test/lint/run-lint-format-strings.py +++ b/test/lint/run-lint-format-strings.py @@ -13,7 +13,7 @@ import re import sys FALSE_POSITIVES = [ - ("src/clientversion.cpp", "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"), + ("src/clientversion.cpp", "strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION)"), ("src/test/translation_tests.cpp", "strprintf(format, arg)"), ]