Skip to content

Commit faff840

Browse files
author
MarcoFalke
committed
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.
1 parent ccc2d3a commit faff840

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/clientversion.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const
7171

7272
std::string CopyrightHolders(const std::string& strPrefix)
7373
{
74-
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
74+
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION).translated;
7575
std::string strCopyrightHolders = strPrefix + copyright_devs;
7676

7777
// Make sure Bitcoin Core copyright is not removed by accident
@@ -85,15 +85,17 @@ std::string LicenseInfo()
8585
{
8686
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";
8787

88-
return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
88+
return CopyrightHolders(strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR).translated + " ") + "\n" +
8989
"\n" +
9090
strprintf(_("Please contribute if you find %s useful. "
91-
"Visit %s for further information about the software.").translated, CLIENT_NAME, "<" CLIENT_URL ">") +
91+
"Visit %s for further information about the software."),
92+
CLIENT_NAME, "<" CLIENT_URL ">")
93+
.translated +
9294
"\n" +
93-
strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
95+
strprintf(_("The source code is available from %s."), URL_SOURCE_CODE).translated +
9496
"\n" +
9597
"\n" +
9698
_("This is experimental software.").translated + "\n" +
97-
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
99+
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s"), "COPYING", "<https://opensource.org/licenses/MIT>").translated +
98100
"\n";
99101
}

test/lint/run-lint-format-strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import sys
1414

1515
FALSE_POSITIVES = [
16-
("src/clientversion.cpp", "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"),
16+
("src/clientversion.cpp", "strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION)"),
1717
("src/test/translation_tests.cpp", "strprintf(format, arg)"),
1818
]
1919

0 commit comments

Comments
 (0)