Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2023-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <tinyformat.h>6#include <util/translation.h>8#include <boost/test/unit_test.hpp>10BOOST_AUTO_TEST_SUITE(translation_tests)12static TranslateFn translate{[](const char * str) { return strprintf("t(%s)", str); }};14// Custom translation function _t(), similar to _() but internal to this test.15consteval auto _t(util::TranslatedLiteral str)16{17str.translate_fn = &translate;18return str;19}21BOOST_AUTO_TEST_CASE(translation_namedparams)22{23bilingual_str arg{"original", "translated"};24bilingual_str result{strprintf(_t("original [%s]"), arg)};25BOOST_CHECK_EQUAL(result.original, "original [original]");26BOOST_CHECK_EQUAL(result.translated, "t(original [translated])");28util::TranslatedLiteral arg2{"original", &translate};29bilingual_str result2{strprintf(_t("original [%s]"), arg2)};30BOOST_CHECK_EQUAL(result2.original, "original [original]");31BOOST_CHECK_EQUAL(result2.translated, "t(original [t(original)])");32}34BOOST_AUTO_TEST_SUITE_END()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.