From 7e87adcd918c7de8fbb0b6df9bb5399e45b5196c Mon Sep 17 00:00:00 2001 From: Dzmitry Neviadomski Date: Mon, 10 Mar 2025 21:08:57 +0300 Subject: [PATCH] Fix building transmission with C++23 (#6832) * fix: operator== should return bool in tr_strbuf Fixes build error with C++20/C++23 error: return type 'auto' of selected 'operator==' function for rewritten '!=' comparison is not 'bool' Signed-off-by: Dzmitry Neviadomski * fix: explicitly specify Blocklist::size() return type as size_t Fixes building with C++20/C++23 error: no matching function for call to 'size' function 'size' with deduced return type cannot be used before it is defined Signed-off-by: Dzmitry Neviadomski * fix: wrap runtime format strings with fmt::runtime in library, daemon and cli fmt::format_string ctor is consteval with C++20 See https://github.com/fmtlib/fmt/issues/2438 Signed-off-by: Dzmitry Neviadomski * fix: wrap runtime format strings with fmt::runtime for GTK client Signed-off-by: Dzmitry Neviadomski * fix: allow to override C and CXX standard via cmdline or env Signed-off-by: Dzmitry Neviadomski * fix: add job to check if transmission compiles with C++23 Signed-off-by: Dzmitry Neviadomski * Address code review by mikedld Signed-off-by: Dzmitry Neviadomski * fix new found fmt build errors Signed-off-by: Dzmitry Neviadomski * Address code review by tearfur Signed-off-by: Dzmitry Neviadomski * fix: make tr_net_init_mgr singleton buildable with C++23 Signed-off-by: Dzmitry Neviadomski --------- Signed-off-by: Dzmitry Neviadomski Co-authored-by: Charles Kerr --- .github/workflows/actions.yml | 64 +++++++++++++++++++++++ CMakeLists.txt | 12 +++-- daemon/daemon.cc | 29 +++++----- gtk/Application.cc | 2 +- gtk/DetailsDialog.cc | 57 +++++++++++--------- gtk/Dialogs.cc | 9 ++-- gtk/FileList.cc | 2 +- gtk/FilterBar.cc | 2 +- gtk/FreeSpaceLabel.cc | 5 +- gtk/MainWindow.cc | 17 +++--- gtk/MakeDialog.cc | 17 +++--- gtk/MessageLogWindow.cc | 2 +- gtk/Notify.cc | 2 +- gtk/PrefsDialog.cc | 8 +-- gtk/RelocateDialog.cc | 2 +- gtk/Session.cc | 19 ++++--- gtk/StatsDialog.cc | 2 +- gtk/SystemTrayIcon.cc | 2 +- gtk/Torrent.cc | 42 ++++++++------- gtk/Utils.cc | 54 +++++++++++-------- gtk/main.cc | 2 +- libtransmission/announcer-http.cc | 4 +- libtransmission/announcer-udp.cc | 9 ++-- libtransmission/announcer.cc | 13 +++-- libtransmission/blocklist.cc | 20 +++---- libtransmission/blocklist.h | 2 +- libtransmission/crypto-utils-ccrypto.cc | 2 +- libtransmission/crypto-utils-mbedtls.cc | 2 +- libtransmission/crypto-utils-openssl.cc | 2 +- libtransmission/crypto-utils-wolfssl.cc | 2 +- libtransmission/inout.cc | 2 +- libtransmission/ip-cache.cc | 7 +-- libtransmission/makemeta.cc | 2 +- libtransmission/net.cc | 15 +++--- libtransmission/open-files.cc | 8 +-- libtransmission/peer-io.cc | 2 +- libtransmission/port-forwarding-natpmp.cc | 9 ++-- libtransmission/port-forwarding-upnp.cc | 14 ++--- libtransmission/port-forwarding.cc | 4 +- libtransmission/rpc-server.cc | 27 ++++++---- libtransmission/rpcimpl.cc | 8 +-- libtransmission/session-id.cc | 4 +- libtransmission/session.cc | 10 ++-- libtransmission/torrent-metainfo.cc | 2 +- libtransmission/torrent.cc | 18 +++---- libtransmission/tr-dht.cc | 4 +- libtransmission/tr-lpd.cc | 4 +- libtransmission/tr-strbuf.h | 2 +- libtransmission/tr-udp.cc | 8 +-- libtransmission/utils.cc | 15 +++--- libtransmission/variant-json.cc | 2 +- libtransmission/variant.cc | 2 +- libtransmission/watchdir-inotify.cc | 14 ++--- libtransmission/watchdir-kqueue.cc | 12 ++--- libtransmission/watchdir.cc | 6 +-- libtransmission/web.cc | 7 +-- utils/create.cc | 7 +-- utils/remote.cc | 2 +- 58 files changed, 375 insertions(+), 249 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index bb5f28859..dd4f2838f 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1028,3 +1028,67 @@ jobs: working-directory: ./android run: | gradle build + + ubuntu-24-04-cxx-23: + needs: [ what-to-make ] + if: ${{ needs.what-to-make.outputs.make-cli == 'true' || needs.what-to-make.outputs.make-daemon == 'true' || needs.what-to-make.outputs.make-gtk == 'true' || needs.what-to-make.outputs.make-qt == 'true' || needs.what-to-make.outputs.make-utils == 'true' }} + runs-on: ubuntu-24.04 + steps: + - name: Show Configuration + run: | + echo '${{ toJSON(needs) }}' + echo '${{ toJSON(runner) }}' + cat /etc/os-release + - name: Get Dependencies + run: | + set -ex + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + appstream \ + ca-certificates \ + clang \ + cmake \ + gettext \ + libcurl4-openssl-dev \ + libdeflate-dev \ + libevent-dev \ + libfmt-dev \ + libminiupnpc-dev \ + libnatpmp-dev \ + libpsl-dev \ + libssl-dev \ + ninja-build + - name: Get Dependencies (GTK) + if: ${{ needs.what-to-make.outputs.make-gtk == 'true' }} + run: sudo apt-get install -y --no-install-recommends libglibmm-2.4-dev libgtkmm-3.0-dev + - name: Get Dependencies (Qt) + if: ${{ needs.what-to-make.outputs.make-qt == 'true' }} + run: sudo apt-get install -y --no-install-recommends qtbase5-dev libqt5svg5-dev qttools5-dev + - name: Get Source + uses: actions/checkout@v4 + with: + submodules: recursive + path: src + - name: Configure + run: | + cmake \ + -S src \ + -B obj \ + -G Ninja \ + -DCMAKE_CXX_STANDARD=23 \ + -DCMAKE_CXX_COMPILER='clang++' \ + -DCMAKE_C_COMPILER='clang' \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_INSTALL_PREFIX=pfx \ + -DENABLE_CLI=${{ (needs.what-to-make.outputs.make-cli == 'true') && 'ON' || 'OFF' }} \ + -DENABLE_DAEMON=${{ (needs.what-to-make.outputs.make-daemon == 'true') && 'ON' || 'OFF' }} \ + -DENABLE_GTK=${{ (needs.what-to-make.outputs.make-gtk == 'true') && 'ON' || 'OFF' }} \ + -DENABLE_MAC=OFF \ + -DENABLE_QT=${{ (needs.what-to-make.outputs.make-qt == 'true') && 'ON' || 'OFF' }} \ + -DENABLE_TESTS=OFF \ + -DENABLE_UTILS=${{ (needs.what-to-make.outputs.make-utils == 'true') && 'ON' || 'OFF' }} \ + -DREBUILD_WEB=OFF \ + -DENABLE_WERROR=ON \ + -DRUN_CLANG_TIDY=OFF + - name: Make + run: cmake --build obj --config RelWithDebInfo -- "-k 0" diff --git a/CMakeLists.txt b/CMakeLists.txt index 616d92064..ecf0676e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,10 +169,14 @@ set(TR_VCS_REVISION_FILE "${PROJECT_SOURCE_DIR}/REVISION") ## Compiler standard version -set(CMAKE_C_STANDARD 11) -set(CMAKE_C_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +if(NOT CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 11) + set(CMAKE_C_STANDARD_REQUIRED ON) +endif() +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif() if(EXISTS ${PROJECT_SOURCE_DIR}/.git) find_package(Git) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 037407f7b..6a94b8ab8 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -194,7 +194,7 @@ auto onFileAdded(tr_session* session, std::string_view dirname, std::string_view if (!tr_file_read(filename, content, &error)) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", basename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -219,7 +219,7 @@ auto onFileAdded(tr_session* session, std::string_view dirname, std::string_view if (tr_torrentNew(ctor, nullptr) == nullptr) { - tr_logAddError(fmt::format(_("Couldn't add torrent file '{path}'"), fmt::arg("path", basename))); + tr_logAddError(fmt::format(fmt::runtime(_("Couldn't add torrent file '{path}'")), fmt::arg("path", basename))); } else { @@ -228,12 +228,12 @@ auto onFileAdded(tr_session* session, std::string_view dirname, std::string_view if (test && trash) { - tr_logAddInfo(fmt::format(_("Removing torrent file '{path}'"), fmt::arg("path", basename))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Removing torrent file '{path}'")), fmt::arg("path", basename))); if (auto error = tr_error{}; !tr_sys_path_remove(filename, &error)) { tr_logAddError(fmt::format( - _("Couldn't remove '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't remove '{path}': {error} ({error_code})")), fmt::arg("path", basename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -634,7 +634,8 @@ bool tr_daemon::parse_args(int argc, char const* const* argv, bool* dump_setting } else { - std::cerr << fmt::format(_("Couldn't parse log level '{level}'"), fmt::arg("level", optstr)) << std::endl; + std::cerr << fmt::format(fmt::runtime(_("Couldn't parse log level '{level}'")), fmt::arg("level", optstr)) + << std::endl; } break; @@ -695,7 +696,7 @@ void tr_daemon::reconfigure() } configDir = tr_sessionGetConfigDir(my_session_); - tr_logAddInfo(fmt::format(_("Reloading settings from '{path}'"), fmt::arg("path", configDir))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Reloading settings from '{path}'")), fmt::arg("path", configDir))); tr_sessionSet(my_session_, load_settings(configDir)); tr_sessionReloadBlocklists(my_session_); @@ -719,7 +720,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; auto const errmsg = fmt::format( - _("Couldn't initialize daemon: {error} ({error_code})"), + fmt::runtime(_("Couldn't initialize daemon: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code)); printMessage(log_stream_, TR_LOG_ERROR, MyName, errmsg, __FILE__, __LINE__); @@ -731,7 +732,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) auto const* const cdir = this->config_dir_.c_str(); auto* session = tr_sessionInit(cdir, true, settings_); tr_sessionSetRPCCallback(session, on_rpc_callback, this); - tr_logAddInfo(fmt::format(_("Loading settings from '{path}'"), fmt::arg("path", cdir))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Loading settings from '{path}'")), fmt::arg("path", cdir))); tr_sessionSaveSettings(session, cdir, settings_); auto sv = std::string_view{}; @@ -752,13 +753,13 @@ int tr_daemon::start([[maybe_unused]] bool foreground) auto const out = std::to_string(getpid()); tr_sys_file_write(fp, std::data(out), std::size(out), nullptr); tr_sys_file_close(fp); - tr_logAddInfo(fmt::format(_("Saved pidfile '{path}'"), fmt::arg("path", sz_pid_filename))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Saved pidfile '{path}'")), fmt::arg("path", sz_pid_filename))); pidfile_created = true; } else { tr_logAddError(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", sz_pid_filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -789,7 +790,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) (void)tr_variantDictFindStrView(&settings_, TR_KEY_watch_dir, &dir); if (!std::empty(dir)) { - tr_logAddInfo(fmt::format(_("Watching '{path}' for new torrent files"), fmt::arg("path", dir))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Watching '{path}' for new torrent files")), fmt::arg("path", dir))); auto handler = [session](std::string_view dirname, std::string_view basename) { @@ -834,7 +835,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't create event: {error} ({error_code})"), + fmt::runtime(_("Couldn't create event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); goto CLEANUP; @@ -844,7 +845,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't add event: {error} ({error_code})"), + fmt::runtime(_("Couldn't add event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); goto CLEANUP; @@ -858,7 +859,7 @@ int tr_daemon::start([[maybe_unused]] bool foreground) { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't launch daemon event loop: {error} ({error_code})"), + fmt::runtime(_("Couldn't launch daemon event loop: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); goto CLEANUP; diff --git a/gtk/Application.cc b/gtk/Application.cc index d06bfa03f..6995fa1c3 100644 --- a/gtk/Application.cc +++ b/gtk/Application.cc @@ -397,7 +397,7 @@ void register_magnet_link_handler() catch (Gio::Error const& e) { gtr_warning(fmt::format( - _("Couldn't register Transmission as a {content_type} handler: {error} ({error_code})"), + fmt::runtime(_("Couldn't register Transmission as a {content_type} handler: {error} ({error_code})")), fmt::arg("content_type", content_type), fmt::arg("error", e.what()), fmt::arg("error_code", static_cast(e.code())))); diff --git a/gtk/DetailsDialog.cc b/gtk/DetailsDialog.cc index aedd287ff..77e80f173 100644 --- a/gtk/DetailsDialog.cc +++ b/gtk/DetailsDialog.cc @@ -718,15 +718,18 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) } else if (!empty_creator && !empty_date) { - str = fmt::format(_("Created by {creator} on {date}"), fmt::arg("creator", creator), fmt::arg("date", datestr)); + str = fmt::format( + fmt::runtime(_("Created by {creator} on {date}")), + fmt::arg("creator", creator), + fmt::arg("date", datestr)); } else if (!empty_creator) { - str = fmt::format(_("Created by {creator}"), fmt::arg("creator", creator)); + str = fmt::format(fmt::runtime(_("Created by {creator}")), fmt::arg("creator", creator)); } else if (!empty_date) { - str = fmt::format(_("Created on {date}"), fmt::arg("date", datestr)); + str = fmt::format(fmt::runtime(_("Created on {date}")), fmt::arg("date", datestr)); } else { @@ -877,7 +880,8 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) [](auto sum, auto const* tor) { return sum + tr_torrentFileCount(tor); }); str = fmt::format( - ngettext("{total_size} in {file_count:L} file", "{total_size} in {file_count:L} files", file_count), + fmt::runtime( + ngettext("{total_size} in {file_count:L} file", "{total_size} in {file_count:L} files", file_count)), fmt::arg("total_size", tr_strlsize(total_size)), fmt::arg("file_count", file_count)); @@ -891,10 +895,10 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) { str += ' '; str += fmt::format( - ngettext( + fmt::runtime(ngettext( "({piece_count} BitTorrent piece @ {piece_size})", "({piece_count} BitTorrent pieces @ {piece_size})", - piece_count), + piece_count)), fmt::arg("piece_count", piece_count), fmt::arg("piece_size", Memory{ piece_size, Memory::Units::Bytes }.to_string())); } @@ -936,7 +940,7 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) if (haveUnchecked == 0 && leftUntilDone == 0) { str = fmt::format( - _("{current_size} ({percent_done}%)"), + fmt::runtime(_("{current_size} ({percent_done}%)")), fmt::arg("current_size", total), fmt::arg("percent_done", buf2)); } @@ -944,7 +948,7 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) { str = fmt::format( // xgettext:no-c-format - _("{current_size} ({percent_done}% of {percent_available}% available)"), + fmt::runtime(_("{current_size} ({percent_done}% of {percent_available}% available)")), fmt::arg("current_size", total), fmt::arg("percent_done", buf2), fmt::arg("percent_available", avail)); @@ -953,7 +957,8 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) { str = fmt::format( // xgettext:no-c-format - _("{current_size} ({percent_done}% of {percent_available}% available; {unverified_size} unverified)"), + fmt::runtime( + _("{current_size} ({percent_done}% of {percent_available}% available; {unverified_size} unverified)")), fmt::arg("current_size", total), fmt::arg("percent_done", buf2), fmt::arg("percent_available", avail), @@ -986,7 +991,7 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) if (failed != 0) { str = fmt::format( - _("{downloaded_size} (+{discarded_size} discarded after failed checksum)"), + fmt::runtime(_("{downloaded_size} (+{discarded_size} discarded after failed checksum)")), fmt::arg("downloaded_size", downloaded_str), fmt::arg("discarded_size", tr_strlsize(failed))); } @@ -1016,7 +1021,7 @@ void DetailsDialog::Impl::refreshInfo(std::vector const& torrents) uint64_t{}, [](auto sum, auto const* st) { return sum + st->sizeWhenDone; }); str = fmt::format( - _("{uploaded_size} (Ratio: {ratio})"), + fmt::runtime(_("{uploaded_size} (Ratio: {ratio})")), fmt::arg("uploaded_size", tr_strlsize(uploaded)), fmt::arg("ratio", tr_strlratio(tr_getRatio(uploaded, denominator)))); } @@ -1812,10 +1817,10 @@ void appendAnnounceInfo(tr_tracker_view const& tracker, time_t const now, Gtk::T { gstr << fmt::format( // {markup_begin} and {markup_end} should surround the peer text - ngettext( + fmt::runtime(ngettext( "Got a list of {markup_begin}{peer_count} peer{markup_end} {time_span_ago}", "Got a list of {markup_begin}{peer_count} peers{markup_end} {time_span_ago}", - tracker.lastAnnouncePeerCount), + tracker.lastAnnouncePeerCount)), fmt::arg("markup_begin", SuccessMarkupBegin), fmt::arg("peer_count", tracker.lastAnnouncePeerCount), fmt::arg("markup_end", SuccessMarkupEnd), @@ -1825,7 +1830,7 @@ void appendAnnounceInfo(tr_tracker_view const& tracker, time_t const now, Gtk::T { gstr << fmt::format( // {markup_begin} and {markup_end} should surround the time_span - _("Peer list request {markup_begin}timed out {time_span_ago}{markup_end}; will retry"), + fmt::runtime(_("Peer list request {markup_begin}timed out {time_span_ago}{markup_end}; will retry")), fmt::arg("markup_begin", TimeoutMarkupBegin), fmt::arg("time_span_ago", time_span_ago), fmt::arg("markup_end", TimeoutMarkupEnd)); @@ -1834,7 +1839,7 @@ void appendAnnounceInfo(tr_tracker_view const& tracker, time_t const now, Gtk::T { gstr << fmt::format( // {markup_begin} and {markup_end} should surround the error - _("Got an error '{markup_begin}{error}{markup_end}' {time_span_ago}"), + fmt::runtime(_("Got an error '{markup_begin}{error}{markup_end}' {time_span_ago}")), fmt::arg("markup_begin", ErrMarkupBegin), fmt::arg("error", Glib::Markup::escape_text(std::data(tracker.lastAnnounceResult))), fmt::arg("markup_end", ErrMarkupEnd), @@ -1854,7 +1859,7 @@ void appendAnnounceInfo(tr_tracker_view const& tracker, time_t const now, Gtk::T gstr << '\n'; gstr << dir_mark; gstr << fmt::format( - _("Asking for more peers {time_span_from_now}"), + fmt::runtime(_("Asking for more peers {time_span_from_now}")), fmt::arg("time_span_from_now", tr_format_time_relative(now, tracker.nextAnnounceTime))); break; @@ -1869,7 +1874,7 @@ void appendAnnounceInfo(tr_tracker_view const& tracker, time_t const now, Gtk::T gstr << dir_mark; gstr << fmt::format( // {markup_begin} and {markup_end} should surround time_span_ago - _("Asked for more peers {markup_begin}{time_span_ago}{markup_end}"), + fmt::runtime(_("Asked for more peers {markup_begin}{time_span_ago}{markup_end}")), fmt::arg("markup_begin", ""), fmt::arg("time_span_ago", tr_format_time_relative(now, tracker.lastAnnounceStartTime)), fmt::arg("markup_end", "")); @@ -1894,7 +1899,8 @@ void appendScrapeInfo(tr_tracker_view const& tracker, time_t const now, Gtk::Tex { gstr << fmt::format( // {markup_begin} and {markup_end} should surround the seeder/leecher text - _("Tracker had {markup_begin}{seeder_count} {seeder_or_seeders} and {leecher_count} {leecher_or_leechers}{markup_end} {time_span_ago}"), + fmt::runtime(_( + "Tracker had {markup_begin}{seeder_count} {seeder_or_seeders} and {leecher_count} {leecher_or_leechers}{markup_end} {time_span_ago}")), fmt::arg("seeder_count", tracker.seederCount), fmt::arg("seeder_or_seeders", ngettext("seeder", "seeders", tracker.seederCount)), fmt::arg("leecher_count", tracker.leecherCount), @@ -1907,7 +1913,7 @@ void appendScrapeInfo(tr_tracker_view const& tracker, time_t const now, Gtk::Tex { gstr << fmt::format( // {markup_begin} and {markup_end} should surround the error text - _("Got a scrape error '{markup_begin}{error}{markup_end}' {time_span_ago}"), + fmt::runtime(_("Got a scrape error '{markup_begin}{error}{markup_end}' {time_span_ago}")), fmt::arg("error", Glib::Markup::escape_text(std::data(tracker.lastScrapeResult))), fmt::arg("time_span_ago", time_span_ago), fmt::arg("markup_begin", ErrMarkupBegin), @@ -1924,7 +1930,7 @@ void appendScrapeInfo(tr_tracker_view const& tracker, time_t const now, Gtk::Tex gstr << '\n'; gstr << dir_mark; gstr << fmt::format( - _("Asking for peer counts in {time_span_from_now}"), + fmt::runtime(_("Asking for peer counts in {time_span_from_now}")), fmt::arg("time_span_from_now", tr_format_time_relative(now, tracker.nextScrapeTime))); break; @@ -1938,7 +1944,7 @@ void appendScrapeInfo(tr_tracker_view const& tracker, time_t const now, Gtk::Tex gstr << '\n'; gstr << dir_mark; gstr << fmt::format( - _("Asked for peer counts {markup_begin}{time_span_ago}{markup_end}"), + fmt::runtime(_("Asked for peer counts {markup_begin}{time_span_ago}{markup_end}")), fmt::arg("markup_begin", ""), fmt::arg("time_span_ago", tr_format_time_relative(now, tracker.lastScrapeStartTime)), fmt::arg("markup_end", "")); @@ -2223,7 +2229,8 @@ EditTrackersDialog::EditTrackersDialog( , torrent_id_(tr_torrentId(torrent)) , urls_view_(gtr_get_widget(builder, "urls_view")) { - set_title(fmt::format(_("{torrent_name} - Edit Trackers"), fmt::arg("torrent_name", tr_torrentName(torrent)))); + set_title( + fmt::format(fmt::runtime(_("{torrent_name} - Edit Trackers")), fmt::arg("torrent_name", tr_torrentName(torrent)))); set_transient_for(parent); urls_view_->get_buffer()->set_text(tr_torrentGetTrackerList(torrent)); @@ -2344,7 +2351,7 @@ AddTrackerDialog::AddTrackerDialog( , torrent_id_(tr_torrentId(torrent)) , url_entry_(gtr_get_widget(builder, "url_entry")) { - set_title(fmt::format(_("{torrent_name} - Add Tracker"), fmt::arg("torrent_name", tr_torrentName(torrent)))); + set_title(fmt::format(fmt::runtime(_("{torrent_name} - Add Tracker")), fmt::arg("torrent_name", tr_torrentName(torrent)))); set_transient_for(parent); auto* const accept = get_widget_for_response(TR_GTK_RESPONSE_TYPE(ACCEPT)); @@ -2639,12 +2646,12 @@ void DetailsDialog::Impl::set_torrents(std::vector const& ids) { int const id = ids.front(); auto const* tor = core_->find_torrent(id); - title = fmt::format(_("{torrent_name} Properties"), fmt::arg("torrent_name", tr_torrentName(tor))); + title = fmt::format(fmt::runtime(_("{torrent_name} Properties")), fmt::arg("torrent_name", tr_torrentName(tor))); } else { title = fmt::format( - ngettext("Properties - {torrent_count:L} Torrent", "Properties - {torrent_count:L} Torrents", len), + fmt::runtime(ngettext("Properties - {torrent_count:L} Torrent", "Properties - {torrent_count:L} Torrents", len)), fmt::arg("torrent_count", len)); } diff --git a/gtk/Dialogs.cc b/gtk/Dialogs.cc index c58c37a61..b7fa96e36 100644 --- a/gtk/Dialogs.cc +++ b/gtk/Dialogs.cc @@ -53,9 +53,12 @@ void gtr_confirm_remove( } auto const primary_text = fmt::format( - !delete_files ? - ngettext("Remove torrent?", "Remove {count:L} torrents?", count) : - ngettext("Delete this torrent's downloaded files?", "Delete these {count:L} torrents' downloaded files?", count), + fmt::runtime( + !delete_files ? ngettext("Remove torrent?", "Remove {count:L} torrents?", count) : + ngettext( + "Delete this torrent's downloaded files?", + "Delete these {count:L} torrents' downloaded files?", + count)), fmt::arg("count", count)); Glib::ustring secondary_text; diff --git a/gtk/FileList.cc b/gtk/FileList.cc index ab7e05ffd..fe2c2d658 100644 --- a/gtk/FileList.cc +++ b/gtk/FileList.cc @@ -854,7 +854,7 @@ void FileList::Impl::on_rename_done_idle(Glib::ustring const& path_string, Glib: auto w = std::make_shared( gtr_widget_get_window(widget_), fmt::format( - _("Couldn't rename '{old_path}' as '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't rename '{old_path}' as '{path}': {error} ({error_code})")), fmt::arg("old_path", path_string), fmt::arg("path", newname), fmt::arg("error", tr_strerror(error)), diff --git a/gtk/FilterBar.cc b/gtk/FilterBar.cc index 2fb695702..4d3b5eb13 100644 --- a/gtk/FilterBar.cc +++ b/gtk/FilterBar.cc @@ -585,7 +585,7 @@ bool FilterBar::Impl::update_count_label() /* set the text */ if (auto const new_markup = visibleCount == std::min(activityCount, trackerCount) ? _("_Show:") : - fmt::format(_("_Show {count:L} of:"), fmt::arg("count", visibleCount)); + fmt::format(fmt::runtime(_("_Show {count:L} of:")), fmt::arg("count", visibleCount)); new_markup != show_lb_->get_label().raw()) { show_lb_->set_markup_with_mnemonic(new_markup); diff --git a/gtk/FreeSpaceLabel.cc b/gtk/FreeSpaceLabel.cc index 15053158e..8ce83f01c 100644 --- a/gtk/FreeSpaceLabel.cc +++ b/gtk/FreeSpaceLabel.cc @@ -53,8 +53,9 @@ bool FreeSpaceLabel::Impl::on_freespace_timer() } auto const capacity = tr_sys_path_get_capacity(dir_); - auto const text = capacity ? fmt::format(_("{disk_space} free"), fmt::arg("disk_space", tr_strlsize(capacity->free))) : - _("Error"); + auto const text = capacity ? + fmt::format(fmt::runtime(_("{disk_space} free")), fmt::arg("disk_space", tr_strlsize(capacity->free))) : + _("Error"); label_.set_markup(fmt::format("{:s}", text)); return true; diff --git a/gtk/MainWindow.cc b/gtk/MainWindow.cc index 526f1074e..b7e974541 100644 --- a/gtk/MainWindow.cc +++ b/gtk/MainWindow.cc @@ -380,8 +380,9 @@ void MainWindow::Impl::syncAltSpeedButton() bool const b = gtr_pref_flag_get(TR_KEY_alt_speed_enabled); alt_speed_button_->set_active(b); alt_speed_button_->set_tooltip_text(fmt::format( - b ? _("Click to disable Alternative Speed Limits\n ({download_speed} down, {upload_speed} up)") : - _("Click to enable Alternative Speed Limits\n ({download_speed} down, {upload_speed} up)"), + fmt::runtime( + b ? _("Click to disable Alternative Speed Limits\n ({download_speed} down, {upload_speed} up)") : + _("Click to enable Alternative Speed Limits\n ({download_speed} down, {upload_speed} up)")), fmt::arg("download_speed", Speed{ gtr_pref_int_get(TR_KEY_alt_speed_down), Speed::Units::KByps }.to_string()), fmt::arg("upload_speed", Speed{ gtr_pref_int_get(TR_KEY_alt_speed_up), Speed::Units::KByps }.to_string()))); } @@ -579,7 +580,9 @@ void MainWindow::Impl::onOptionsClicked() update_menu( ratio_menu_info_, - fmt::format(_("Stop at Ratio ({ratio})"), fmt::arg("ratio", tr_strlratio(gtr_pref_double_get(TR_KEY_ratio_limit)))), + fmt::format( + fmt::runtime(_("Stop at Ratio ({ratio})")), + fmt::arg("ratio", tr_strlratio(gtr_pref_double_get(TR_KEY_ratio_limit)))), TR_KEY_ratio_limit_enabled); } @@ -760,13 +763,13 @@ void MainWindow::Impl::updateStats() if (auto const pch = gtr_pref_string_get(TR_KEY_statusbar_stats); pch == "session-ratio") { auto const stats = tr_sessionGetStats(session); - buf = fmt::format(_("Ratio: {ratio}"), fmt::arg("ratio", tr_strlratio(stats.ratio))); + buf = fmt::format(fmt::runtime(_("Ratio: {ratio}")), fmt::arg("ratio", tr_strlratio(stats.ratio))); } else if (pch == "session-transfer") { auto const stats = tr_sessionGetStats(session); buf = fmt::format( - C_("current session totals", "Down: {downloaded_size}, Up: {uploaded_size}"), + fmt::runtime(C_("current session totals", "Down: {downloaded_size}, Up: {uploaded_size}")), fmt::arg("downloaded_size", tr_strlsize(stats.downloadedBytes)), fmt::arg("uploaded_size", tr_strlsize(stats.uploadedBytes))); } @@ -774,14 +777,14 @@ void MainWindow::Impl::updateStats() { auto const stats = tr_sessionGetCumulativeStats(session); buf = fmt::format( - C_("all-time totals", "Down: {downloaded_size}, Up: {uploaded_size}"), + fmt::runtime(C_("all-time totals", "Down: {downloaded_size}, Up: {uploaded_size}")), fmt::arg("downloaded_size", tr_strlsize(stats.downloadedBytes)), fmt::arg("uploaded_size", tr_strlsize(stats.uploadedBytes))); } else /* default is total-ratio */ { auto const stats = tr_sessionGetCumulativeStats(session); - buf = fmt::format(_("Ratio: {ratio}"), fmt::arg("ratio", tr_strlratio(stats.ratio))); + buf = fmt::format(fmt::runtime(_("Ratio: {ratio}")), fmt::arg("ratio", tr_strlratio(stats.ratio))); } stats_lb_->set_text(buf); diff --git a/gtk/MakeDialog.cc b/gtk/MakeDialog.cc index f10d96ff3..37edbd099 100644 --- a/gtk/MakeDialog.cc +++ b/gtk/MakeDialog.cc @@ -191,7 +191,7 @@ bool MakeProgressDialog::onProgressDialogRefresh() auto const base = Glib::path_get_basename(builder_.top()); if (!is_done) { - str = fmt::format(_("Creating '{path}'"), fmt::arg("path", base)); + str = fmt::format(fmt::runtime(_("Creating '{path}'")), fmt::arg("path", base)); } else { @@ -204,13 +204,13 @@ bool MakeProgressDialog::onProgressDialogRefresh() if (!error) { - str = fmt::format(_("Created '{path}'"), fmt::arg("path", base)); + str = fmt::format(fmt::runtime(_("Created '{path}'")), fmt::arg("path", base)); success = true; } else { str = fmt::format( - _("Couldn't create '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't create '{path}': {error} ({error_code})")), fmt::arg("path", base), fmt::arg("error", error.message()), fmt::arg("error_code", error.code())); @@ -228,7 +228,7 @@ bool MakeProgressDialog::onProgressDialogRefresh() { /* how much data we've scanned through to generate checksums */ str = fmt::format( - _("Scanned {file_size}"), + fmt::runtime(_("Scanned {file_size}")), fmt::arg("file_size", tr_strlsize(static_cast(piece_index) * builder_.piece_size()))); } @@ -389,15 +389,18 @@ void MakeDialog::Impl::updatePiecesLabel() else { gstr += fmt::format( - ngettext("{total_size} in {file_count:L} file", "{total_size} in {file_count:L} files", builder_->file_count()), + fmt::runtime(ngettext( + "{total_size} in {file_count:L} file", + "{total_size} in {file_count:L} files", + builder_->file_count())), fmt::arg("total_size", tr_strlsize(builder_->total_size())), fmt::arg("file_count", builder_->file_count())); gstr += ' '; gstr += fmt::format( - ngettext( + fmt::runtime(ngettext( "({piece_count} BitTorrent piece @ {piece_size})", "({piece_count} BitTorrent pieces @ {piece_size})", - builder_->piece_count()), + builder_->piece_count())), fmt::arg("piece_count", builder_->piece_count()), fmt::arg("piece_size", Memory{ builder_->piece_size(), Memory::Units::Bytes }.to_string())); } diff --git a/gtk/MessageLogWindow.cc b/gtk/MessageLogWindow.cc index 8da3f257a..335a689a1 100644 --- a/gtk/MessageLogWindow.cc +++ b/gtk/MessageLogWindow.cc @@ -241,7 +241,7 @@ void MessageLogWindow::Impl::doSave(std::string const& filename) auto w = std::make_shared( window_, fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", Glib::filename_to_utf8(filename)), fmt::arg("error", e.code().message()), fmt::arg("error_code", e.code().value())), diff --git a/gtk/Notify.cc b/gtk/Notify.cc index ee443b7f0..95b4adba4 100644 --- a/gtk/Notify.cc +++ b/gtk/Notify.cc @@ -145,7 +145,7 @@ void dbus_proxy_ready_callback(Glib::RefPtr& res) catch (Glib::Error const& e) { gtr_warning(fmt::format( - _("Couldn't create proxy for '{bus}': {error} ({error_code})"), + fmt::runtime(_("Couldn't create proxy for '{bus}': {error} ({error_code})")), fmt::arg("bus", NotificationsDbusName), fmt::arg("error", TR_GLIB_EXCEPTION_WHAT(e)), fmt::arg("error_code", e.code()))); diff --git a/gtk/PrefsDialog.cc b/gtk/PrefsDialog.cc index d7514f096..9b7292cd4 100644 --- a/gtk/PrefsDialog.cc +++ b/gtk/PrefsDialog.cc @@ -130,7 +130,7 @@ public: template static void localize_label(T& widget, ArgTs&&... args) { - widget.set_label(fmt::format(widget.get_label().raw(), std::forward(args)...)); + widget.set_label(fmt::format(fmt::runtime(widget.get_label().raw()), std::forward(args)...)); } private: @@ -564,7 +564,7 @@ void PrivacyPage::updateBlocklistText() { int const n = tr_blocklistGetRuleCount(core_->get_session()); auto const msg = fmt::format( - ngettext("Blocklist has {count:L} entry", "Blocklist has {count:L} entries", n), + fmt::runtime(ngettext("Blocklist has {count:L} entry", "Blocklist has {count:L} entries", n)), fmt::arg("count", n)); label_->set_text(msg); } @@ -972,9 +972,9 @@ void NetworkPage::updatePortStatusText() portLabel_->set_markup( portTestStatus_[Session::PORT_TEST_IPV4] == portTestStatus_[Session::PORT_TEST_IPV6] ? - fmt::format(_("Status: {status}"), fmt::arg("status", status_ipv4)) : + fmt::format(fmt::runtime(_("Status: {status}")), fmt::arg("status", status_ipv4)) : fmt::format( - _("Status: {status_ipv4} (IPv4), {status_ipv6} (IPv6)"), + fmt::runtime(_("Status: {status_ipv4} (IPv4), {status_ipv6} (IPv6)")), fmt::arg("status_ipv4", status_ipv4), fmt::arg("status_ipv6", status_ipv6))); } diff --git a/gtk/RelocateDialog.cc b/gtk/RelocateDialog.cc index a96fe1b51..7d26348bb 100644 --- a/gtk/RelocateDialog.cc +++ b/gtk/RelocateDialog.cc @@ -83,7 +83,7 @@ void RelocateDialog::Impl::startMovingNextTorrent() torrent_ids_.pop_back(); message_dialog_->set_message( - fmt::format(_("Moving '{torrent_name}'"), fmt::arg("torrent_name", tr_torrentName(tor))), + fmt::format(fmt::runtime(_("Moving '{torrent_name}'")), fmt::arg("torrent_name", tr_torrentName(tor))), true); } diff --git a/gtk/Session.cc b/gtk/Session.cc index b180b4062..2452e430b 100644 --- a/gtk/Session.cc +++ b/gtk/Session.cc @@ -319,7 +319,7 @@ void rename_torrent(Glib::RefPtr const& file) catch (Glib::Error const& e) { gtr_message(fmt::format( - _("Couldn't rename '{old_path}' as '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't rename '{old_path}' as '{path}': {error} ({error_code})")), fmt::arg("old_path", old_name), fmt::arg("path", new_name), fmt::arg("error", e.what()), @@ -794,7 +794,7 @@ void Session::Impl::add_file_async_callback( if (!file->load_contents_finish(result, contents, length)) { - gtr_message(fmt::format(_("Couldn't read '{path}'"), fmt::arg("path", file->get_parse_name()))); + gtr_message(fmt::format(fmt::runtime(_("Couldn't read '{path}'")), fmt::arg("path", file->get_parse_name()))); } else if (tr_ctorSetMetainfo(ctor, contents, length, nullptr)) { @@ -808,7 +808,7 @@ void Session::Impl::add_file_async_callback( catch (Glib::Error const& e) { gtr_message(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", file->get_parse_name()), fmt::arg("error", e.what()), fmt::arg("error_code", e.code()))); @@ -859,7 +859,10 @@ bool Session::Impl::add_file(Glib::RefPtr const& file, bool do_start, else { tr_ctorFree(ctor); - std::cerr << fmt::format(_("Couldn't add torrent file '{path}'"), fmt::arg("path", file->get_parse_name())) << '\n'; + std::cerr << fmt::format( + fmt::runtime(_("Couldn't add torrent file '{path}'")), + fmt::arg("path", file->get_parse_name())) + << '\n'; } return handled; @@ -1085,7 +1088,8 @@ bool gtr_inhibit_hibernation(guint32& cookie) } catch (Glib::Error const& e) { - tr_logAddError(fmt::format(_("Couldn't inhibit desktop hibernation: {error}"), fmt::arg("error", e.what()))); + tr_logAddError( + fmt::format(fmt::runtime(_("Couldn't inhibit desktop hibernation: {error}")), fmt::arg("error", e.what()))); } return success; @@ -1110,7 +1114,8 @@ void gtr_uninhibit_hibernation(guint inhibit_cookie) } catch (Glib::Error const& e) { - tr_logAddError(fmt::format(_("Couldn't inhibit desktop hibernation: {error}"), fmt::arg("error", e.what()))); + tr_logAddError( + fmt::format(fmt::runtime(_("Couldn't inhibit desktop hibernation: {error}")), fmt::arg("error", e.what()))); } } @@ -1224,7 +1229,7 @@ bool core_read_rpc_response_idle(tr_variant& response) } else { - gtr_warning(fmt::format(_("Couldn't find pending RPC request for tag {tag}"), fmt::arg("tag", tag))); + gtr_warning(fmt::format(fmt::runtime(_("Couldn't find pending RPC request for tag {tag}")), fmt::arg("tag", tag))); } } diff --git a/gtk/StatsDialog.cc b/gtk/StatsDialog.cc index e4a4f4a8c..57f99f7a3 100644 --- a/gtk/StatsDialog.cc +++ b/gtk/StatsDialog.cc @@ -70,7 +70,7 @@ void setLabelFromRatio(Gtk::Label* l, double d) auto startedTimesText(uint64_t n) { - return fmt::format(ngettext("Started {count:L} time", "Started {count:L} times", n), fmt::arg("count", n)); + return fmt::format(fmt::runtime(ngettext("Started {count:L} time", "Started {count:L} times", n)), fmt::arg("count", n)); } } // namespace diff --git a/gtk/SystemTrayIcon.cc b/gtk/SystemTrayIcon.cc index 4025eb368..5140e7b0a 100644 --- a/gtk/SystemTrayIcon.cc +++ b/gtk/SystemTrayIcon.cc @@ -204,7 +204,7 @@ std::string SystemTrayIcon::Impl::make_tooltip_text() const { auto const* const session = core_->get_session(); return fmt::format( - _("{upload_speed} ▲ {download_speed} ▼"), + fmt::runtime(_("{upload_speed} ▲ {download_speed} ▼")), fmt::arg("upload_speed", Speed{ tr_sessionGetRawSpeed_KBps(session, TR_UP), Speed::Units::KByps }.to_string()), fmt::arg("download_speed", Speed{ tr_sessionGetRawSpeed_KBps(session, TR_DOWN), Speed::Units::KByps }.to_string())); } diff --git a/gtk/Torrent.cc b/gtk/Torrent.cc index 0994a8d42..294157909 100644 --- a/gtk/Torrent.cc +++ b/gtk/Torrent.cc @@ -436,7 +436,7 @@ Glib::ustring Torrent::Impl::get_short_status_text() const case TR_STATUS_CHECK: return fmt::format( // xgettext:no-c-format - _("Verifying local data ({percent_done}% tested)"), + fmt::runtime(_("Verifying local data ({percent_done}% tested)")), fmt::arg("percent_done", cache_.recheck_progress.to_string())); case TR_STATUS_DOWNLOAD: @@ -444,7 +444,7 @@ Glib::ustring Torrent::Impl::get_short_status_text() const return fmt::format( "{:s} {:s}", get_short_transfer_text(), - fmt::format(_("Ratio: {ratio}"), fmt::arg("ratio", tr_strlratio(cache_.ratio)))); + fmt::format(fmt::runtime(_("Ratio: {ratio}")), fmt::arg("ratio", tr_strlratio(cache_.ratio)))); default: return {}; @@ -463,7 +463,7 @@ Glib::ustring Torrent::Impl::get_long_progress_text() const { // 50 MB of 200 MB (25%) gstr += fmt::format( - _("{current_size} of {complete_size} ({percent_done}%)"), + fmt::runtime(_("{current_size} of {complete_size} ({percent_done}%)")), fmt::arg("current_size", tr_strlsize(haveTotal)), fmt::arg("complete_size", tr_strlsize(cache_.size_when_done)), fmt::arg("percent_done", cache_.percent_done.to_string())); @@ -473,7 +473,8 @@ Glib::ustring Torrent::Impl::get_long_progress_text() const // 50 MB of 200 MB (25%), uploaded 30 MB (Ratio: X%, Goal: Y%) gstr += fmt::format( // xgettext:no-c-format - _("{current_size} of {complete_size} ({percent_complete}%), uploaded {uploaded_size} (Ratio: {ratio}, Goal: {seed_ratio})"), + fmt::runtime(_( + "{current_size} of {complete_size} ({percent_complete}%), uploaded {uploaded_size} (Ratio: {ratio}, Goal: {seed_ratio})")), fmt::arg("current_size", tr_strlsize(haveTotal)), fmt::arg("complete_size", tr_strlsize(cache_.total_size)), fmt::arg("percent_complete", cache_.percent_complete.to_string()), @@ -485,7 +486,8 @@ Glib::ustring Torrent::Impl::get_long_progress_text() const { gstr += fmt::format( // xgettext:no-c-format - _("{current_size} of {complete_size} ({percent_complete}%), uploaded {uploaded_size} (Ratio: {ratio})"), + fmt::runtime( + _("{current_size} of {complete_size} ({percent_complete}%), uploaded {uploaded_size} (Ratio: {ratio})")), fmt::arg("current_size", tr_strlsize(haveTotal)), fmt::arg("complete_size", tr_strlsize(cache_.total_size)), fmt::arg("percent_complete", cache_.percent_complete.to_string()), @@ -495,7 +497,7 @@ Glib::ustring Torrent::Impl::get_long_progress_text() const else if (cache_.has_seed_ratio) // seed, seed ratio { gstr += fmt::format( - _("{complete_size}, uploaded {uploaded_size} (Ratio: {ratio}, Goal: {seed_ratio})"), + fmt::runtime(_("{complete_size}, uploaded {uploaded_size} (Ratio: {ratio}, Goal: {seed_ratio})")), fmt::arg("complete_size", tr_strlsize(cache_.total_size)), fmt::arg("uploaded_size", tr_strlsize(cache_.uploaded_ever)), fmt::arg("ratio", tr_strlratio(cache_.ratio)), @@ -504,7 +506,7 @@ Glib::ustring Torrent::Impl::get_long_progress_text() const else // seed, no seed ratio { gstr += fmt::format( - _("{complete_size}, uploaded {uploaded_size} (Ratio: {ratio})"), + fmt::runtime(_("{complete_size}, uploaded {uploaded_size} (Ratio: {ratio})")), fmt::arg("complete_size", tr_strlsize(cache_.total_size)), fmt::arg("uploaded_size", tr_strlsize(cache_.uploaded_ever)), fmt::arg("ratio", tr_strlratio(cache_.ratio))); @@ -637,13 +639,13 @@ Glib::ustring Torrent::Impl::get_error_text() const switch (cache_.error_code) { case TR_STAT_TRACKER_WARNING: - return fmt::format(_("Tracker warning: '{warning}'"), fmt::arg("warning", cache_.error_message)); + return fmt::format(fmt::runtime(_("Tracker warning: '{warning}'")), fmt::arg("warning", cache_.error_message)); case TR_STAT_TRACKER_ERROR: - return fmt::format(_("Tracker Error: '{error}'"), fmt::arg("error", cache_.error_message)); + return fmt::format(fmt::runtime(_("Tracker Error: '{error}'")), fmt::arg("error", cache_.error_message)); case TR_STAT_LOCAL_ERROR: - return fmt::format(_("Local error: '{error}'"), fmt::arg("error", cache_.error_message)); + return fmt::format(fmt::runtime(_("Local error: '{error}'")), fmt::arg("error", cache_.error_message)); default: return {}; @@ -665,11 +667,11 @@ Glib::ustring Torrent::Impl::get_activity_text() const if (!cache_.has_metadata) { return fmt::format( - ngettext( + fmt::runtime(ngettext( // xgettext:no-c-format "Downloading metadata from {active_count} connected peer ({percent_done}% done)", "Downloading metadata from {active_count} connected peers ({percent_done}% done)", - cache_.peers_connected), + cache_.peers_connected)), fmt::arg("active_count", cache_.peers_connected), fmt::arg("percent_done", cache_.metadata_percent_complete.to_string())); } @@ -677,10 +679,10 @@ Glib::ustring Torrent::Impl::get_activity_text() const if (cache_.peers_sending_to_us != 0 && cache_.webseeds_sending_to_us != 0) { return fmt::format( - ngettext( + fmt::runtime(ngettext( "Downloading from {active_count} of {connected_count} connected peer and webseed", "Downloading from {active_count} of {connected_count} connected peers and webseeds", - cache_.peers_connected + cache_.webseeds_sending_to_us), + cache_.peers_connected + cache_.webseeds_sending_to_us)), fmt::arg("active_count", cache_.peers_sending_to_us + cache_.webseeds_sending_to_us), fmt::arg("connected_count", cache_.peers_connected + cache_.webseeds_sending_to_us)); } @@ -688,27 +690,27 @@ Glib::ustring Torrent::Impl::get_activity_text() const if (cache_.webseeds_sending_to_us != 0) { return fmt::format( - ngettext( + fmt::runtime(ngettext( "Downloading from {active_count} webseed", "Downloading from {active_count} webseeds", - cache_.webseeds_sending_to_us), + cache_.webseeds_sending_to_us)), fmt::arg("active_count", cache_.webseeds_sending_to_us)); } return fmt::format( - ngettext( + fmt::runtime(ngettext( "Downloading from {active_count} of {connected_count} connected peer", "Downloading from {active_count} of {connected_count} connected peers", - cache_.peers_connected), + cache_.peers_connected)), fmt::arg("active_count", cache_.peers_sending_to_us), fmt::arg("connected_count", cache_.peers_connected)); case TR_STATUS_SEED: return fmt::format( - ngettext( + fmt::runtime(ngettext( "Seeding to {active_count} of {connected_count} connected peer", "Seeding to {active_count} of {connected_count} connected peers", - cache_.peers_connected), + cache_.peers_connected)), fmt::arg("active_count", cache_.peers_getting_from_us), fmt::arg("connected_count", cache_.peers_connected)); diff --git a/gtk/Utils.cc b/gtk/Utils.cc index d6ac64acd..13f74dc3c 100644 --- a/gtk/Utils.cc +++ b/gtk/Utils.cc @@ -132,28 +132,30 @@ std::string tr_format_future_time(time_t seconds) if (auto const days_from_now = seconds / 86400U; days_from_now > 0U) { return fmt::format( - ngettext("{days_from_now:L} day from now", "{days_from_now:L} days from now", days_from_now), + fmt::runtime(ngettext("{days_from_now:L} day from now", "{days_from_now:L} days from now", days_from_now)), fmt::arg("days_from_now", days_from_now)); } if (auto const hours_from_now = (seconds % 86400U) / 3600U; hours_from_now > 0U) { return fmt::format( - ngettext("{hours_from_now:L} hour from now", "{hours_from_now:L} hours from now", hours_from_now), + fmt::runtime(ngettext("{hours_from_now:L} hour from now", "{hours_from_now:L} hours from now", hours_from_now)), fmt::arg("hours_from_now", hours_from_now)); } if (auto const minutes_from_now = (seconds % 3600U) / 60U; minutes_from_now > 0U) { return fmt::format( - ngettext("{minutes_from_now:L} minute from now", "{minutes_from_now:L} minutes from now", minutes_from_now), + fmt::runtime( + ngettext("{minutes_from_now:L} minute from now", "{minutes_from_now:L} minutes from now", minutes_from_now)), fmt::arg("minutes_from_now", minutes_from_now)); } if (auto const seconds_from_now = seconds % 60U; seconds_from_now > 0U) { return fmt::format( - ngettext("{seconds_from_now:L} second from now", "{seconds_from_now:L} seconds from now", seconds_from_now), + fmt::runtime( + ngettext("{seconds_from_now:L} second from now", "{seconds_from_now:L} seconds from now", seconds_from_now)), fmt::arg("seconds_from_now", seconds_from_now)); } @@ -164,27 +166,29 @@ std::string tr_format_past_time(time_t seconds) { if (auto const days_ago = seconds / 86400U; days_ago > 0U) { - return fmt::format(ngettext("{days_ago:L} day ago", "{days_ago:L} days ago", days_ago), fmt::arg("days_ago", days_ago)); + return fmt::format( + fmt::runtime(ngettext("{days_ago:L} day ago", "{days_ago:L} days ago", days_ago)), + fmt::arg("days_ago", days_ago)); } if (auto const hours_ago = (seconds % 86400U) / 3600U; hours_ago > 0U) { return fmt::format( - ngettext("{hours_ago:L} hour ago", "{hours_ago:L} hours ago", hours_ago), + fmt::runtime(ngettext("{hours_ago:L} hour ago", "{hours_ago:L} hours ago", hours_ago)), fmt::arg("hours_ago", hours_ago)); } if (auto const minutes_ago = (seconds % 3600U) / 60U; minutes_ago > 0U) { return fmt::format( - ngettext("{minutes_ago:L} minute ago", "{minutes_ago:L} minutes ago", minutes_ago), + fmt::runtime(ngettext("{minutes_ago:L} minute ago", "{minutes_ago:L} minutes ago", minutes_ago)), fmt::arg("minutes_ago", minutes_ago)); } if (auto const seconds_ago = seconds % 60U; seconds_ago > 0U) { return fmt::format( - ngettext("{seconds_ago:L} second ago", "{seconds_ago:L} seconds ago", seconds_ago), + fmt::runtime(ngettext("{seconds_ago:L} second ago", "{seconds_ago:L} seconds ago", seconds_ago)), fmt::arg("seconds_ago", seconds_ago)); } @@ -197,22 +201,26 @@ std::string tr_format_time(time_t timestamp) { if (auto const days = timestamp / 86400U; days > 0U) { - return fmt::format(ngettext("{days:L} day", "{days:L} days", days), fmt::arg("days", days)); + return fmt::format(fmt::runtime(ngettext("{days:L} day", "{days:L} days", days)), fmt::arg("days", days)); } if (auto const hours = (timestamp % 86400U) / 3600U; hours > 0U) { - return fmt::format(ngettext("{hours:L} hour", "{hours:L} hours", hours), fmt::arg("hours", hours)); + return fmt::format(fmt::runtime(ngettext("{hours:L} hour", "{hours:L} hours", hours)), fmt::arg("hours", hours)); } if (auto const minutes = (timestamp % 3600U) / 60U; minutes > 0U) { - return fmt::format(ngettext("{minutes:L} minute", "{minutes:L} minutes", minutes), fmt::arg("minutes", minutes)); + return fmt::format( + fmt::runtime(ngettext("{minutes:L} minute", "{minutes:L} minutes", minutes)), + fmt::arg("minutes", minutes)); } if (auto const seconds = timestamp % 60U; seconds > 0U) { - return fmt::format(ngettext("{seconds:L} second", "{seconds:L} seconds", seconds), fmt::arg("seconds", seconds)); + return fmt::format( + fmt::runtime(ngettext("{seconds:L} second", "{seconds:L} seconds", seconds)), + fmt::arg("seconds", seconds)); } return _("now"); @@ -223,28 +231,28 @@ std::string tr_format_time_left(time_t timestamp) if (auto const days_left = timestamp / 86400U; days_left > 0U) { return fmt::format( - ngettext("{days_left:L} day left", "{days_left:L} days left", days_left), + fmt::runtime(ngettext("{days_left:L} day left", "{days_left:L} days left", days_left)), fmt::arg("days_left", days_left)); } if (auto const hours_left = (timestamp % 86400U) / 3600U; hours_left > 0U) { return fmt::format( - ngettext("{hours_left:L} hour left", "{hours_left:L} hours left", hours_left), + fmt::runtime(ngettext("{hours_left:L} hour left", "{hours_left:L} hours left", hours_left)), fmt::arg("hours_left", hours_left)); } if (auto const minutes_left = (timestamp % 3600U) / 60U; minutes_left > 0U) { return fmt::format( - ngettext("{minutes_left:L} minute left", "{minutes_left:L} minutes left", minutes_left), + fmt::runtime(ngettext("{minutes_left:L} minute left", "{minutes_left:L} minutes left", minutes_left)), fmt::arg("minutes_left", minutes_left)); } if (auto const seconds_left = timestamp % 60U; seconds_left > 0U) { return fmt::format( - ngettext("{seconds_left:L} second left", "{seconds_left:L} seconds left", seconds_left), + fmt::runtime(ngettext("{seconds_left:L} second left", "{seconds_left:L} seconds left", seconds_left)), fmt::arg("seconds_left", seconds_left)); } @@ -263,13 +271,13 @@ void gtr_add_torrent_error_dialog(Gtk::Widget& child, tr_torrent* duplicate_torr if (duplicate_torrent != nullptr) { secondary = fmt::format( - _("The torrent file '{path}' is already in use by '{torrent_name}'."), + fmt::runtime(_("The torrent file '{path}' is already in use by '{torrent_name}'.")), fmt::arg("path", filename), fmt::arg("torrent_name", tr_torrentName(duplicate_torrent))); } else { - secondary = fmt::format(_("Couldn't add torrent file '{path}'"), fmt::arg("path", filename)); + secondary = fmt::format(fmt::runtime(_("Couldn't add torrent file '{path}'")), fmt::arg("path", filename)); } auto w = std::make_shared( @@ -534,7 +542,7 @@ bool gtr_file_trash_or_remove(std::string const& filename, tr_error* error) { error->set(e.code(), TR_GLIB_EXCEPTION_WHAT(e)); gtr_message(fmt::format( - _("Couldn't move '{path}' to trash: {error} ({error_code})"), + fmt::runtime(_("Couldn't move '{path}' to trash: {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -552,7 +560,7 @@ bool gtr_file_trash_or_remove(std::string const& filename, tr_error* error) { error->set(e.code(), TR_GLIB_EXCEPTION_WHAT(e)); gtr_message(fmt::format( - _("Couldn't remove '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't remove '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -641,7 +649,7 @@ void gtr_open_uri(Glib::ustring const& uri) if (!opened) { - gtr_message(fmt::format(_("Couldn't open '{url}'"), fmt::arg("url", uri))); + gtr_message(fmt::format(fmt::runtime(_("Couldn't open '{url}'")), fmt::arg("url", uri))); } } } @@ -852,13 +860,13 @@ void gtr_unrecognized_url_dialog(Gtk::Widget& parent, Glib::ustring const& url) auto w = std::make_shared( gtr_widget_get_window(parent), - fmt::format(_("Unsupported URL: '{url}'"), fmt::arg("url", url)), + fmt::format(fmt::runtime(_("Unsupported URL: '{url}'")), fmt::arg("url", url)), false /*use markup*/, TR_GTK_MESSAGE_TYPE(ERROR), TR_GTK_BUTTONS_TYPE(CLOSE), true /*modal*/); - gstr += fmt::format(_("Transmission doesn't know how to use '{url}'"), fmt::arg("url", url)); + gstr += fmt::format(fmt::runtime(_("Transmission doesn't know how to use '{url}'")), fmt::arg("url", url)); if (tr_magnet_metainfo{}.parseMagnet(url.raw())) { diff --git a/gtk/main.cc b/gtk/main.cc index c5d415d5a..1431ad5af 100644 --- a/gtk/main.cc +++ b/gtk/main.cc @@ -103,7 +103,7 @@ int main(int argc, char** argv) fmt::print(stderr, "{}\n", TR_GLIB_EXCEPTION_WHAT(e)); fmt::print( stderr, - _("Run '{program} --help' to see a full list of available command line options.\n"), + fmt::runtime(_("Run '{program} --help' to see a full list of available command line options.\n")), fmt::arg("program", *argv)); return 1; } diff --git a/libtransmission/announcer-http.cc b/libtransmission/announcer-http.cc index 68de60a3b..8a66ac2a4 100644 --- a/libtransmission/announcer-http.cc +++ b/libtransmission/announcer-http.cc @@ -454,7 +454,7 @@ void tr_announcerParseHttpAnnounceResponse(tr_announce_response& response, std:: { tr_logAddWarn( fmt::format( - _("Couldn't parse announce response: {error} ({error_code})"), + fmt::runtime(_("Couldn't parse announce response: {error} ({error_code})")), fmt::arg("error", error.message()), fmt::arg("error_code", error.code())), log_name); @@ -674,7 +674,7 @@ void tr_announcerParseHttpScrapeResponse(tr_scrape_response& response, std::stri { tr_logAddWarn( fmt::format( - _("Couldn't parse scrape response: {error} ({error_code})"), + fmt::runtime(_("Couldn't parse scrape response: {error} ({error_code})")), fmt::arg("error", error.message()), fmt::arg("error_code", error.code())), log_name); diff --git a/libtransmission/announcer-udp.cc b/libtransmission/announcer-udp.cc index 325026c4d..2e45a3db5 100644 --- a/libtransmission/announcer-udp.cc +++ b/libtransmission/announcer-udp.cc @@ -371,9 +371,10 @@ struct tau_tracker } else if (action == TAU_ACTION_ERROR) { - std::string errmsg = !std::empty(buf) ? - buf.to_string() : - fmt::format(_("{ip_protocol} connection failed"), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(ip_protocol))); + std::string errmsg = !std::empty(buf) ? buf.to_string() : + fmt::format( + fmt::runtime(_("{ip_protocol} connection failed")), + fmt::arg("ip_protocol", tr_ip_protocol_to_sv(ip_protocol))); fail_all(true, false, errmsg); logdbg(log_name(), std::move(errmsg)); } @@ -505,7 +506,7 @@ private: logwarn( log_name(), fmt::format( - _("Couldn't look up '{address}:{port}' in {ip_protocol}: {error} ({error_code})"), + fmt::runtime(_("Couldn't look up '{address}:{port}' in {ip_protocol}: {error} ({error_code})")), fmt::arg("address", host), fmt::arg("port", port.host()), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(ip_protocol)), diff --git a/libtransmission/announcer.cc b/libtransmission/announcer.cc index 6e40995b5..4a037b874 100644 --- a/libtransmission/announcer.cc +++ b/libtransmission/announcer.cc @@ -179,7 +179,7 @@ public: } else { - tr_logAddError(fmt::format(_("Unsupported URL: '{url}'"), fmt::arg("url", scrape_sv))); + tr_logAddError(fmt::format(fmt::runtime(_("Unsupported URL: '{url}'")), fmt::arg("url", scrape_sv))); } } @@ -198,7 +198,7 @@ public: } else { - tr_logAddWarn(fmt::format(_("Unsupported URL: '{url}'"), fmt::arg("url", announce_sv))); + tr_logAddWarn(fmt::format(fmt::runtime(_("Unsupported URL: '{url}'")), fmt::arg("url", announce_sv))); } } @@ -890,7 +890,10 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e) { tr_logAddErrorTier( tier, - fmt::format(_("Announce error: {error} ({url})"), fmt::arg("error", err), fmt::arg("url", announce_url))); + fmt::format( + fmt::runtime(_("Announce error: {error} ({url})")), + fmt::arg("error", err), + fmt::arg("url", announce_url))); } else { @@ -899,10 +902,10 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e) tr_logAddWarnTier( tier, fmt::format( - tr_ngettext( + fmt::runtime(tr_ngettext( "Announce error: {error} (Retrying in {count} second) ({url})", "Announce error: {error} (Retrying in {count} seconds) ({url})", - interval), + interval)), fmt::arg("error", err), fmt::arg("count", interval), fmt::arg("url", announce_url))); diff --git a/libtransmission/blocklist.cc b/libtransmission/blocklist.cc index 9ae103efe..e1bf5a0b8 100644 --- a/libtransmission/blocklist.cc +++ b/libtransmission/blocklist.cc @@ -59,7 +59,7 @@ void save(std::string_view filename, address_range_t const* ranges, size_t n_ran if (!out.is_open()) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -70,7 +70,7 @@ void save(std::string_view filename, address_range_t const* ranges, size_t n_ran !out.write(reinterpret_cast(ranges), n_ranges * sizeof(*ranges))) { tr_logAddWarn(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -78,7 +78,8 @@ void save(std::string_view filename, address_range_t const* ranges, size_t n_ran else { tr_logAddInfo(fmt::format( - tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", n_ranges), + fmt::runtime( + tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", n_ranges)), fmt::arg("path", tr_sys_path_basename(filename)), fmt::arg("count", n_ranges))); } @@ -237,7 +238,7 @@ auto parseFile(std::string_view filename) if (!in.is_open()) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -256,7 +257,7 @@ auto parseFile(std::string_view filename) else { // don't try to display the actual lines - it causes issues - tr_logAddWarn(fmt::format(_("Couldn't parse line: '{line}'"), fmt::arg("line", line_number))); + tr_logAddWarn(fmt::format(fmt::runtime(_("Couldn't parse line: '{line}'")), fmt::arg("line", line_number))); } } in.close(); @@ -335,7 +336,7 @@ void Blocklists::Blocklist::ensureLoaded() const if (error) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", bin_file_), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -350,7 +351,7 @@ void Blocklists::Blocklist::ensureLoaded() const if (!in) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", bin_file_), fmt::arg("error", tr_strerror(errno)), fmt::arg("error_code", errno))); @@ -400,7 +401,8 @@ void Blocklists::Blocklist::ensureLoaded() const } tr_logAddInfo(fmt::format( - tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", std::size(rules_)), + fmt::runtime( + tr_ngettext("Blocklist '{path}' has {count} entry", "Blocklist '{path}' has {count} entries", std::size(rules_))), fmt::arg("path", tr_sys_path_basename(bin_file_)), fmt::arg("count", std::size(rules_)))); } @@ -470,7 +472,7 @@ std::optional Blocklists::Blocklist::saveNew( if (error) { tr_logAddWarn(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", src_file), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/blocklist.h b/libtransmission/blocklist.h index 70a3083a7..8a3d463a8 100644 --- a/libtransmission/blocklist.h +++ b/libtransmission/blocklist.h @@ -78,7 +78,7 @@ private: [[nodiscard]] bool contains(tr_address const& addr) const; - [[nodiscard]] auto size() const + [[nodiscard]] size_t size() const { ensureLoaded(); diff --git a/libtransmission/crypto-utils-ccrypto.cc b/libtransmission/crypto-utils-ccrypto.cc index ea05781a7..79864309c 100644 --- a/libtransmission/crypto-utils-ccrypto.cc +++ b/libtransmission/crypto-utils-ccrypto.cc @@ -70,7 +70,7 @@ void log_ccrypto_error(CCCryptorStatus error_code, char const* file, long line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "CCrypto"), fmt::arg("error", ccrypto_error_to_str(error_code)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/crypto-utils-mbedtls.cc b/libtransmission/crypto-utils-mbedtls.cc index fad55b40d..41fe277d5 100644 --- a/libtransmission/crypto-utils-mbedtls.cc +++ b/libtransmission/crypto-utils-mbedtls.cc @@ -42,7 +42,7 @@ void log_mbedtls_error(int error_code, char const* file, int line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "MbedTLS"), fmt::arg("error", error_message), fmt::arg("error_code", error_code))); diff --git a/libtransmission/crypto-utils-openssl.cc b/libtransmission/crypto-utils-openssl.cc index 03a3106d6..3f0fe26ce 100644 --- a/libtransmission/crypto-utils-openssl.cc +++ b/libtransmission/crypto-utils-openssl.cc @@ -61,7 +61,7 @@ void log_openssl_error(char const* file, int line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "OpenSSL"), fmt::arg("error", std::data(buf)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/crypto-utils-wolfssl.cc b/libtransmission/crypto-utils-wolfssl.cc index 0438974ef..78c5e4232 100644 --- a/libtransmission/crypto-utils-wolfssl.cc +++ b/libtransmission/crypto-utils-wolfssl.cc @@ -45,7 +45,7 @@ void log_wolfssl_error(int error_code, char const* file, int line) line, TR_LOG_ERROR, fmt::format( - _("{crypto_library} error: {error} ({error_code})"), + fmt::runtime(_("{crypto_library} error: {error} ({error_code})")), fmt::arg("crypto_library", "WolfSSL"), fmt::arg("error", wc_GetErrorString(error_code)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/inout.cc b/libtransmission/inout.cc index 604a9251e..ed61774e6 100644 --- a/libtransmission/inout.cc +++ b/libtransmission/inout.cc @@ -115,7 +115,7 @@ bool write_entire_buf(tr_sys_file_t const fd, uint64_t file_offset, uint8_t cons error.set( err, fmt::format( - _("Couldn't get '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't get '{path}': {error} ({error_code})")), fmt::arg("path", tor.file_subpath(file_index)), fmt::arg("error", tr_strerror(err)), fmt::arg("error_code", err))); diff --git a/libtransmission/ip-cache.cc b/libtransmission/ip-cache.cc index d5abe8ebe..feb90c314 100644 --- a/libtransmission/ip-cache.cc +++ b/libtransmission/ip-cache.cc @@ -271,7 +271,7 @@ void tr_ip_cache::update_source_addr(tr_address_type type) noexcept { set_source_addr(*source_addr); tr_logAddDebug(fmt::format( - _("Successfully updated source {protocol} address to {ip}"), + fmt::runtime(_("Successfully updated source {protocol} address to {ip}")), fmt::arg("protocol", protocol), fmt::arg("ip", source_addr->display_name()))); } @@ -285,7 +285,8 @@ void tr_ip_cache::update_source_addr(tr_address_type type) noexcept { stop_timer(type); // No point in retrying has_ip_protocol = false; - tr_logAddInfo(fmt::format(_("Your machine does not support {protocol}"), fmt::arg("protocol", protocol))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Your machine does not support {protocol}")), fmt::arg("protocol", protocol))); } } @@ -310,7 +311,7 @@ void tr_ip_cache::on_response_ip_query(tr_address_type type, tr_web::FetchRespon upkeep_timers_[type]->set_interval(UpkeepInterval); tr_logAddDebug(fmt::format( - _("Successfully updated global {type} address to {ip} using {url}"), + fmt::runtime(_("Successfully updated global {type} address to {ip} using {url}")), fmt::arg("type", protocol), fmt::arg("ip", addr->display_name()), fmt::arg("url", IPQueryServices[type][ix_service]))); diff --git a/libtransmission/makemeta.cc b/libtransmission/makemeta.cc index 33ffae047..6e398c4aa 100644 --- a/libtransmission/makemeta.cc +++ b/libtransmission/makemeta.cc @@ -77,7 +77,7 @@ void walkTree(std::string_view const top, std::string_view const subpath, std::s if (error) { tr_logAddWarn(fmt::format( - _("Skipping '{path}': {error} ({error_code})"), + fmt::runtime(_("Skipping '{path}': {error} ({error_code})")), fmt::arg("path", path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/net.cc b/libtransmission/net.cc index 120f54c71..f3e9141a4 100644 --- a/libtransmission/net.cc +++ b/libtransmission/net.cc @@ -189,7 +189,7 @@ tr_socket_t createSocket(int domain, int type) if (sockerrno != EAFNOSUPPORT) { tr_logAddWarn(fmt::format( - _("Couldn't create socket: {error} ({error_code})"), + fmt::runtime(_("Couldn't create socket: {error} ({error_code})")), fmt::arg("error", tr_net_strerror(sockerrno)), fmt::arg("error_code", sockerrno))); } @@ -266,7 +266,7 @@ tr_socket_t tr_net_open_peer_socket(tr_session* session, tr_socket_address const if (bind(s, reinterpret_cast(&source_sock), sourcelen) == -1) { tr_logAddWarn(fmt::format( - _("Couldn't set source address {address} on {socket}: {error} ({error_code})"), + fmt::runtime(_("Couldn't set source address {address} on {socket}: {error} ({error_code})")), fmt::arg("address", source_addr.display_name()), fmt::arg("socket", s), fmt::arg("error", tr_net_strerror(sockerrno)), @@ -285,7 +285,7 @@ tr_socket_t tr_net_open_peer_socket(tr_session* session, tr_socket_address const (tmperrno != ECONNREFUSED && tmperrno != ENETUNREACH && tmperrno != EHOSTUNREACH) || addr.is_ipv4()) { tr_logAddWarn(fmt::format( - _("Couldn't connect socket {socket} to {address}:{port}: {error} ({error_code})"), + fmt::runtime(_("Couldn't connect socket {socket} to {address}:{port}: {error} ({error_code})")), fmt::arg("socket", s), fmt::arg("address", addr.display_name()), fmt::arg("port", port.host()), @@ -343,9 +343,10 @@ tr_socket_t tr_netBindTCPImpl(tr_address const& addr, tr_port port, bool suppres if (!suppress_msgs) { tr_logAddError(fmt::format( - err == EADDRINUSE ? - _("Couldn't bind port {port} on {address}: {error} ({error_code}) -- Is another copy of Transmission already running?") : - _("Couldn't bind port {port} on {address}: {error} ({error_code})"), + fmt::runtime( + err == EADDRINUSE ? + _("Couldn't bind port {port} on {address}: {error} ({error_code}) -- Is another copy of Transmission already running?") : + _("Couldn't bind port {port} on {address}: {error} ({error_code})")), fmt::arg("address", addr.display_name()), fmt::arg("port", port.host()), fmt::arg("error", tr_net_strerror(err)), @@ -798,7 +799,7 @@ int tr_address::compare(tr_address const& that) const noexcept // <=> std::string tr_socket_address::display_name(tr_address const& address, tr_port port) noexcept { - return fmt::format(address.is_ipv6() ? "[{:s}]:{:d}" : "{:s}:{:d}", address.display_name(), port.host()); + return fmt::format(fmt::runtime(address.is_ipv6() ? "[{:s}]:{:d}" : "{:s}:{:d}"), address.display_name(), port.host()); } bool tr_socket_address::is_valid_for_peers(tr_peer_from from) const noexcept diff --git a/libtransmission/open-files.cc b/libtransmission/open-files.cc index 429eb40bf..749cdc147 100644 --- a/libtransmission/open-files.cc +++ b/libtransmission/open-files.cc @@ -167,7 +167,7 @@ std::optional tr_open_files::get( if (!tr_sys_dir_create(dir, TR_SYS_DIR_CREATE_PARENTS, 0777, &error)) { tr_logAddError(fmt::format( - _("Couldn't create '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't create '{path}': {error} ({error_code})")), fmt::arg("path", dir), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -189,7 +189,7 @@ std::optional tr_open_files::get( if (!is_open(fd)) { tr_logAddError(fmt::format( - _("Couldn't open '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't open '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -217,7 +217,7 @@ std::optional tr_open_files::get( if (!success) { tr_logAddError(fmt::format( - _("Couldn't preallocate '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't preallocate '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -236,7 +236,7 @@ std::optional tr_open_files::get( if (resize_needed && !tr_sys_file_truncate(fd, file_size, &error)) { tr_logAddWarn(fmt::format( - _("Couldn't truncate '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't truncate '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/peer-io.cc b/libtransmission/peer-io.cc index 805865e8c..a3e451ad8 100644 --- a/libtransmission/peer-io.cc +++ b/libtransmission/peer-io.cc @@ -663,7 +663,7 @@ void tr_peerIo::on_utp_state_change(int state) } else { - tr_logAddErrorIo(this, fmt::format(_("Unknown state: {state}"), fmt::arg("state", state))); + tr_logAddErrorIo(this, fmt::format(fmt::runtime(_("Unknown state: {state}")), fmt::arg("state", state))); } } diff --git a/libtransmission/port-forwarding-natpmp.cc b/libtransmission/port-forwarding-natpmp.cc index 7d4d0054c..b268c9dc2 100644 --- a/libtransmission/port-forwarding-natpmp.cc +++ b/libtransmission/port-forwarding-natpmp.cc @@ -87,7 +87,8 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled) { auto str = std::array{}; evutil_inet_ntop(AF_INET, &response.pnu.publicaddress.addr, std::data(str), std::size(str)); - tr_logAddInfo(fmt::format(_("Found public address '{address}'"), fmt::arg("address", std::data(str)))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Found public address '{address}'")), fmt::arg("address", std::data(str)))); state_ = State::Idle; } else if (val != NATPMP_TRYAGAIN) @@ -124,7 +125,8 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled) { auto const unmapped_port = tr_port::from_host(resp.pnu.newportmapping.privateport); - tr_logAddInfo(fmt::format(_("Port {port} is no longer forwarded"), fmt::arg("port", unmapped_port.host()))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Port {port} is no longer forwarded")), fmt::arg("port", unmapped_port.host()))); if (local_port_ == unmapped_port) { @@ -172,7 +174,8 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled) renew_time_ = tr_time() + (resp.pnu.newportmapping.lifetime / 2); local_port_ = tr_port::from_host(resp.pnu.newportmapping.privateport); advertised_port_ = tr_port::from_host(resp.pnu.newportmapping.mappedpublicport); - tr_logAddInfo(fmt::format(_("Port {port} forwarded successfully"), fmt::arg("port", local_port_.host()))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Port {port} forwarded successfully")), fmt::arg("port", local_port_.host()))); } else if (val != NATPMP_TRYAGAIN) { diff --git a/libtransmission/port-forwarding-upnp.cc b/libtransmission/port-forwarding-upnp.cc index a4146e0df..d1d4c3aa5 100644 --- a/libtransmission/port-forwarding-upnp.cc +++ b/libtransmission/port-forwarding-upnp.cc @@ -269,8 +269,10 @@ tr_port_forwarding_state tr_upnpPulse( #endif == UPNP_IGD_VALID_CONNECTED) { - tr_logAddInfo(fmt::format(_("Found Internet Gateway Device '{url}'"), fmt::arg("url", handle->urls.controlURL))); - tr_logAddInfo(fmt::format(_("Local Address is '{address}'"), fmt::arg("address", lanaddr.data()))); + tr_logAddInfo(fmt::format( + fmt::runtime(_("Found Internet Gateway Device '{url}'")), + fmt::arg("url", handle->urls.controlURL))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Local Address is '{address}'")), fmt::arg("address", lanaddr.data()))); handle->state = UpnpState::Idle; handle->lanaddr = std::data(lanaddr); } @@ -295,7 +297,7 @@ tr_port_forwarding_state tr_upnpPulse( get_specific_port_mapping_entry(handle, "UDP") != UPNPCOMMAND_SUCCESS)) { tr_logAddInfo(fmt::format( - _("Local port {local_port} is not forwarded to {advertised_port}"), + fmt::runtime(_("Local port {local_port} is not forwarded to {advertised_port}")), fmt::arg("local_port", handle->local_port.host()), fmt::arg("advertised_port", handle->advertised_port.host()))); handle->isMapped = false; @@ -307,7 +309,7 @@ tr_port_forwarding_state tr_upnpPulse( tr_upnpDeletePortMapping(handle, "UDP", handle->advertised_port); tr_logAddInfo(fmt::format( - _("Stopping port forwarding through '{url}', service '{type}'"), + fmt::runtime(_("Stopping port forwarding through '{url}', service '{type}'")), fmt::arg("url", handle->urls.controlURL), fmt::arg("type", handle->data.first.servicetype))); @@ -340,7 +342,7 @@ tr_port_forwarding_state tr_upnpPulse( } tr_logAddDebug(fmt::format( - _("Port forwarding through '{url}', service '{type}'. (local address: {address}:{port})"), + fmt::runtime(_("Port forwarding through '{url}', service '{type}'. (local address: {address}:{port})")), fmt::arg("url", handle->urls.controlURL), fmt::arg("type", handle->data.first.servicetype), fmt::arg("address", handle->lanaddr), @@ -349,7 +351,7 @@ tr_port_forwarding_state tr_upnpPulse( if (handle->isMapped) { tr_logAddInfo(fmt::format( - _("Forwarded local port {local_port} to {advertised_port}"), + fmt::runtime(_("Forwarded local port {local_port} to {advertised_port}")), fmt::arg("local_port", local_port.host()), fmt::arg("advertised_port", advertised_port.host()))); handle->advertised_port = advertised_port; diff --git a/libtransmission/port-forwarding.cc b/libtransmission/port-forwarding.cc index 4161c0850..e9129f6b8 100644 --- a/libtransmission/port-forwarding.cc +++ b/libtransmission/port-forwarding.cc @@ -198,7 +198,7 @@ private: { mediator_.on_port_forwarded(result.advertised_port); tr_logAddInfo(fmt::format( - _("Mapped private port {private_port} to public port {public_port}"), + fmt::runtime(_("Mapped private port {private_port} to public port {public_port}")), fmt::arg("private_port", result.local_port.host()), fmt::arg("public_port", result.advertised_port.host()))); } @@ -214,7 +214,7 @@ private: if (auto const new_state = state(); new_state != old_state) { tr_logAddInfo(fmt::format( - _("State changed from '{old_state}' to '{state}'"), + fmt::runtime(_("State changed from '{old_state}' to '{state}'")), fmt::arg("old_state", getNatStateStr(old_state)), fmt::arg("state", getNatStateStr(new_state)))); } diff --git a/libtransmission/rpc-server.cc b/libtransmission/rpc-server.cc index c92323abd..c58880375 100644 --- a/libtransmission/rpc-server.cc +++ b/libtransmission/rpc-server.cc @@ -101,7 +101,7 @@ public: if (std::size(src) >= TrUnixAddrStrLen) { tr_logAddError(fmt::format( - _("Unix socket path must be fewer than {count} characters (including '{prefix}' prefix)"), + fmt::runtime(_("Unix socket path must be fewer than {count} characters (including '{prefix}' prefix)")), fmt::arg("count", TrUnixAddrStrLen - 1), fmt::arg("prefix", TrUnixSocketPrefix))); return false; @@ -654,8 +654,9 @@ bool bindUnixSocket( if (chmod(addr.sun_path, socket_mode) != 0) { - tr_logAddWarn( - fmt::format(_("Couldn't set RPC socket mode to {mode:#o}, defaulting to 0755"), fmt::arg("mode", socket_mode))); + tr_logAddWarn(fmt::format( + fmt::runtime(_("Couldn't set RPC socket mode to {mode:#o}, defaulting to 0755")), + fmt::arg("mode", socket_mode))); } return evhttp_bind_listener(httpd, lev) != nullptr; @@ -717,10 +718,10 @@ void start_server(tr_rpc_server* server) } tr_logAddError(fmt::format( - tr_ngettext( + fmt::runtime(tr_ngettext( "Couldn't bind to {address} after {count} attempt, giving up", "Couldn't bind to {address} after {count} attempts, giving up", - ServerStartRetryCount), + ServerStartRetryCount)), fmt::arg("address", addr_port_str), fmt::arg("count", ServerStartRetryCount))); } @@ -729,7 +730,9 @@ void start_server(tr_rpc_server* server) evhttp_set_gencb(httpd, handle_request, server); server->httpd.reset(httpd); - tr_logAddInfo(fmt::format(_("Listening for RPC and Web requests on '{address}'"), fmt::arg("address", addr_port_str))); + tr_logAddInfo(fmt::format( + fmt::runtime(_("Listening for RPC and Web requests on '{address}'")), + fmt::arg("address", addr_port_str))); } rpc_server_start_retry_cancel(server); @@ -757,7 +760,7 @@ void stop_server(tr_rpc_server* server) } tr_logAddInfo(fmt::format( - _("Stopped listening for RPC and Web requests on '{address}'"), + fmt::runtime(_("Stopped listening for RPC and Web requests on '{address}'")), fmt::arg("address", server->bind_address_->to_string(server->port())))); } @@ -779,7 +782,7 @@ auto parse_whitelist(std::string_view whitelist) auto const pos = whitelist.find_first_of(" ,;"sv); auto const token = tr_strv_strip(whitelist.substr(0, pos)); list.emplace_back(token); - tr_logAddInfo(fmt::format(_("Added '{entry}' to host whitelist"), fmt::arg("entry", token))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Added '{entry}' to host whitelist")), fmt::arg("entry", token))); whitelist = pos == std::string_view::npos ? ""sv : whitelist.substr(pos + 1); } @@ -899,7 +902,8 @@ void tr_rpc_server::load(Settings&& settings) { // NOTE: bind_address_ is default initialized to INADDR_ANY tr_logAddWarn(fmt::format( - _("The '{key}' setting is '{value}' but must be an IPv4 or IPv6 address or a Unix socket path. Using default value '0.0.0.0'"), + fmt::runtime(_( + "The '{key}' setting is '{value}' but must be an IPv4 or IPv6 address or a Unix socket path. Using default value '0.0.0.0'")), fmt::arg("key", tr_quark_get_string_view(TR_KEY_rpc_bind_address)), fmt::arg("value", settings_.bind_address_str))); } @@ -912,7 +916,7 @@ void tr_rpc_server::load(Settings&& settings) if (this->is_enabled()) { auto const rpc_uri = bind_address_->to_string(port()) + settings_.url; - tr_logAddInfo(fmt::format(_("Serving RPC and Web requests on {address}"), fmt::arg("address", rpc_uri))); + tr_logAddInfo(fmt::format(fmt::runtime(_("Serving RPC and Web requests on {address}")), fmt::arg("address", rpc_uri))); session->run_in_session_thread(start_server, this); if (this->is_whitelist_enabled()) @@ -928,7 +932,8 @@ void tr_rpc_server::load(Settings&& settings) if (!std::empty(web_client_dir_)) { - tr_logAddInfo(fmt::format(_("Serving RPC and Web requests from '{path}'"), fmt::arg("path", web_client_dir_))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Serving RPC and Web requests from '{path}'")), fmt::arg("path", web_client_dir_))); } } diff --git a/libtransmission/rpcimpl.cc b/libtransmission/rpcimpl.cc index 7256fa5af..f77061a76 100644 --- a/libtransmission/rpcimpl.cc +++ b/libtransmission/rpcimpl.cc @@ -1155,7 +1155,7 @@ void onPortTested(tr_web::FetchResponse const& web_response) tr_idle_function_done( data, fmt::format( - _("Couldn't test port: {error} ({error_code})"), + fmt::runtime(_("Couldn't test port: {error} ({error_code})")), fmt::arg("error", tr_webGetResponseStr(status)), fmt::arg("error_code", status))); return; @@ -1210,7 +1210,7 @@ void onBlocklistFetched(tr_web::FetchResponse const& web_response) tr_idle_function_done( data, fmt::format( - _("Couldn't fetch blocklist: {error} ({error_code})"), + fmt::runtime(_("Couldn't fetch blocklist: {error} ({error_code})")), fmt::arg("error", tr_webGetResponseStr(status)), fmt::arg("error_code", status))); return; @@ -1255,7 +1255,7 @@ void onBlocklistFetched(tr_web::FetchResponse const& web_response) tr_idle_function_done( data, fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -1337,7 +1337,7 @@ void onMetadataFetched(tr_web::FetchResponse const& web_response) tr_idle_function_done( data->data, fmt::format( - _("Couldn't fetch torrent: {error} ({error_code})"), + fmt::runtime(_("Couldn't fetch torrent: {error} ({error_code})")), fmt::arg("error", tr_webGetResponseStr(status)), fmt::arg("error_code", status))); } diff --git a/libtransmission/session-id.cc b/libtransmission/session-id.cc index d51d4c999..75fd6741f 100644 --- a/libtransmission/session-id.cc +++ b/libtransmission/session-id.cc @@ -65,7 +65,7 @@ tr_sys_file_t create_lockfile(std::string_view session_id) if (error) { tr_logAddWarn(fmt::format( - _("Couldn't create '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't create '{path}': {error} ({error_code})")), fmt::arg("path", lockfile_path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -147,7 +147,7 @@ bool tr_session_id::is_local(std::string_view session_id) noexcept if (error) { tr_logAddWarn(fmt::format( - _("Couldn't open session lock file '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't open session lock file '{path}': {error} ({error_code})")), fmt::arg("path", lockfile_path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/session.cc b/libtransmission/session.cc index 4289b1bfc..f0dda4b4e 100644 --- a/libtransmission/session.cc +++ b/libtransmission/session.cc @@ -412,7 +412,7 @@ tr_session::BoundSocket::BoundSocket( } tr_logAddInfo(fmt::format( - _("Listening to incoming peer connections on {hostport}"), + fmt::runtime(_("Listening to incoming peer connections on {hostport}")), fmt::arg("hostport", tr_socket_address::display_name(addr, port)))); event_add(ev_.get(), nullptr); } @@ -730,7 +730,8 @@ void tr_session::initImpl(init_data& data) blocklists_.load(blocklist_dir_, blocklist_enabled()); - tr_logAddInfo(fmt::format(_("Transmission version {version} starting"), fmt::arg("version", LONG_VERSION_STRING))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Transmission version {version} starting")), fmt::arg("version", LONG_VERSION_STRING))); setSettings(settings, true); @@ -1418,7 +1419,8 @@ void tr_sessionClose(tr_session* session, size_t timeout_secs) TR_ASSERT(session != nullptr); TR_ASSERT(!session->am_in_session_thread()); - tr_logAddInfo(fmt::format(_("Transmission version {version} shutting down"), fmt::arg("version", LONG_VERSION_STRING))); + tr_logAddInfo( + fmt::format(fmt::runtime(_("Transmission version {version} shutting down")), fmt::arg("version", LONG_VERSION_STRING))); auto closed_promise = std::promise{}; auto closed_future = closed_promise.get_future(); @@ -1491,7 +1493,7 @@ void session_load_torrents(tr_session* session, tr_ctor* ctor, std::promiseerror().set_local_error(fmt::format( - _("Couldn't use metainfo from '{path}' for '{magnet}': {error} ({error_code})"), + fmt::runtime(_("Couldn't use metainfo from '{path}' for '{magnet}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("magnet", tor->magnet()), fmt::arg("error", error.message()), @@ -398,7 +398,7 @@ void torrentCallScript(tr_torrent const* tor, std::string const& script) { "TR_TORRENT_TRACKERS"sv, trackers_str }, }; - tr_logAddInfoTor(tor, fmt::format(_("Calling script '{path}'"), fmt::arg("path", script))); + tr_logAddInfoTor(tor, fmt::format(fmt::runtime(_("Calling script '{path}'")), fmt::arg("path", script))); auto error = tr_error{}; if (!tr_spawn_async(std::data(cmd), env, TR_IF_WIN32("\\", "/"), &error)) @@ -406,7 +406,7 @@ void torrentCallScript(tr_torrent const* tor, std::string const& script) tr_logAddWarnTor( tor, fmt::format( - _("Couldn't call script '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't call script '{path}': {error} ({error_code})")), fmt::arg("path", script), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -717,7 +717,7 @@ void tr_torrentRemoveInSessionThread( tor->is_deleting_ = false; tor->error().set_local_error(fmt::format( - _("Couldn't remove all torrent files: {error} ({error_code})"), + fmt::runtime(_("Couldn't remove all torrent files: {error} ({error_code})")), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); tr_torrentStop(tor); @@ -1002,7 +1002,7 @@ void tr_torrent::init(tr_ctor const& ctor) if (error) { this->error().set_local_error(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", file_path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -1100,7 +1100,7 @@ void tr_torrent::set_location_in_session_thread(std::string_view const path, boo if (error) { this->error().set_local_error(fmt::format( - _("Couldn't move '{old_path}' to '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't move '{old_path}' to '{path}': {error} ({error_code})")), fmt::arg("old_path", current_dir()), fmt::arg("path", path), fmt::arg("error", error.message()), @@ -1606,7 +1606,7 @@ void tr_torrent::update_file_path(tr_file_index_t file, std::optional has_ tr_logAddErrorTor( this, fmt::format( - _("Couldn't move '{old_path}' to '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't move '{old_path}' to '{path}': {error} ({error_code})")), fmt::arg("old_path", oldpath), fmt::arg("path", newpath), fmt::arg("error", error.message()), @@ -1991,7 +1991,7 @@ bool tr_torrent::set_announce_list(tr_announce_list announce_list) if (save_error.has_value()) { error().set_local_error(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", save_error.message()), fmt::arg("error_code", save_error.code()))); @@ -2044,7 +2044,7 @@ void tr_torrent::on_tracker_response(tr_tracker_event const* event) tr_logAddWarnTor( this, fmt::format( - _("Tracker warning: '{warning}' ({url})"), + fmt::runtime(_("Tracker warning: '{warning}' ({url})")), fmt::arg("warning", event->text), fmt::arg("url", tr_urlTrackerLogName(event->announce_url)))); error_.set_tracker_warning(event->announce_url, event->text); diff --git a/libtransmission/tr-dht.cc b/libtransmission/tr-dht.cc index 9fc7b750d..f72a669c1 100644 --- a/libtransmission/tr-dht.cc +++ b/libtransmission/tr-dht.cc @@ -550,7 +550,7 @@ private: if (line_stream.bad() || std::empty(addrstr)) { tr_logAddWarn(fmt::format( - _("Couldn't parse '{filename}' line: '{line}'"), + fmt::runtime(_("Couldn't parse '{filename}' line: '{line}'")), fmt::arg("filename", filename), fmt::arg("line", line))); } @@ -574,7 +574,7 @@ private: if (int const rc = getaddrinfo(name, port_str.c_str(), &hints, &info); rc != 0) { tr_logAddWarn(fmt::format( - _("Couldn't look up '{address}:{port}': {error} ({error_code})"), + fmt::runtime(_("Couldn't look up '{address}:{port}': {error} ({error_code})")), fmt::arg("address", name), fmt::arg("port", port_in.host()), fmt::arg("error", gai_strerror(rc)), diff --git a/libtransmission/tr-lpd.cc b/libtransmission/tr-lpd.cc index 9d4070e73..daa4e3925 100644 --- a/libtransmission/tr-lpd.cc +++ b/libtransmission/tr-lpd.cc @@ -267,7 +267,7 @@ private: tr_net_close_socket(mcast_sockets_[TR_AF_INET]); mcast_sockets_[TR_AF_INET] = TR_BAD_SOCKET; tr_logAddWarn(fmt::format( - _("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})"), + fmt::runtime(_("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})")), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(TR_AF_INET)), fmt::arg("error", tr_strerror(err)), fmt::arg("error_code", err))); @@ -280,7 +280,7 @@ private: tr_net_close_socket(mcast_sockets_[TR_AF_INET6]); mcast_sockets_[TR_AF_INET6] = TR_BAD_SOCKET; tr_logAddWarn(fmt::format( - _("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})"), + fmt::runtime(_("Couldn't initialize {ip_protocol} LPD: {error} ({error_code})")), fmt::arg("ip_protocol", tr_ip_protocol_to_sv(TR_AF_INET6)), fmt::arg("error", tr_strerror(err)), fmt::arg("error_code", err))); diff --git a/libtransmission/tr-strbuf.h b/libtransmission/tr-strbuf.h index 134c48053..c2b009cae 100644 --- a/libtransmission/tr-strbuf.h +++ b/libtransmission/tr-strbuf.h @@ -131,7 +131,7 @@ public: } template - [[nodiscard]] constexpr auto operator==(ContiguousRange const& x) const noexcept + [[nodiscard]] constexpr bool operator==(ContiguousRange const& x) const noexcept { return sv() == x; } diff --git a/libtransmission/tr-udp.cc b/libtransmission/tr-udp.cc index 0b72d33e2..9aeb94325 100644 --- a/libtransmission/tr-udp.cc +++ b/libtransmission/tr-udp.cc @@ -177,7 +177,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't make IPv4 socket non-blocking {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't make IPv4 socket non-blocking {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -188,7 +188,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't bind IPv4 socket {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't bind IPv4 socket {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -222,7 +222,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't make IPv6 socket non-blocking {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't make IPv6 socket non-blocking {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -233,7 +233,7 @@ tr_session::tr_udp_core::tr_udp_core(tr_session& session, tr_port udp_port) { auto const error_code = errno; tr_logAddWarn(fmt::format( - _("Couldn't bind IPv6 socket {address}: {error} ({error_code})"), + fmt::runtime(_("Couldn't bind IPv6 socket {address}: {error} ({error_code})")), fmt::arg("address", tr_socket_address::display_name(addr, udp_port_)), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); diff --git a/libtransmission/utils.cc b/libtransmission/utils.cc index bd707dd49..d1a631a67 100644 --- a/libtransmission/utils.cc +++ b/libtransmission/utils.cc @@ -135,7 +135,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (*error) { tr_logAddError(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -144,7 +144,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (!info || !info->isFile()) { - tr_logAddError(fmt::format(_("Couldn't read '{path}': Not a regular file"), fmt::arg("path", filename))); + tr_logAddError(fmt::format(fmt::runtime(_("Couldn't read '{path}': Not a regular file")), fmt::arg("path", filename))); error->set(TR_ERROR_EISDIR, "Not a regular file"sv); return false; } @@ -154,7 +154,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (fd == TR_BAD_SYS_FILE) { tr_logAddError(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -165,7 +165,7 @@ bool tr_file_read(std::string_view filename, std::vector& contents, tr_err if (!tr_sys_file_read(fd, std::data(contents), info->size, nullptr, error)) { tr_logAddError(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error->message()), fmt::arg("error_code", error->code()))); @@ -633,7 +633,7 @@ bool tr_file_move(std::string_view oldpath_in, std::string_view newpath_in, bool if (auto log_error = tr_error{}; !tr_sys_path_remove(oldpath, &log_error)) { tr_logAddError(fmt::format( - _("Couldn't remove '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't remove '{path}': {error} ({error_code})")), fmt::arg("path", oldpath), fmt::arg("error", log_error.message()), fmt::arg("error_code", log_error.code()))); @@ -769,8 +769,11 @@ public: } private: - static inline std::unique_ptr instance; + static std::unique_ptr instance; }; + +std::unique_ptr tr_net_init_mgr::instance; + } // namespace tr_net_init_impl } // namespace diff --git a/libtransmission/variant-json.cc b/libtransmission/variant-json.cc index 4ac47cc08..9c87e1c65 100644 --- a/libtransmission/variant-json.cc +++ b/libtransmission/variant-json.cc @@ -238,7 +238,7 @@ std::optional tr_variant_serde::parse_json(std::string_view input) error_.set( EILSEQ, fmt::format( - _("Couldn't parse JSON at position {position} '{text}': {error} ({error_code})"), + fmt::runtime(_("Couldn't parse JSON at position {position} '{text}': {error} ({error_code})")), fmt::arg("position", pos), fmt::arg("text", std::string_view{ begin + pos, std::min(size_t{ 16U }, size - pos) }), fmt::arg("error", rapidjson::GetParseError_En(err_code)), diff --git a/libtransmission/variant.cc b/libtransmission/variant.cc index a3c14405a..2b6d12331 100644 --- a/libtransmission/variant.cc +++ b/libtransmission/variant.cc @@ -873,7 +873,7 @@ bool tr_variant_serde::to_file(tr_variant const& var, std::string_view filename) if (error_) { tr_logAddError(fmt::format( - _("Couldn't save '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't save '{path}': {error} ({error_code})")), fmt::arg("path", filename), fmt::arg("error", error_.message()), fmt::arg("error_code", error_.code()))); diff --git a/libtransmission/watchdir-inotify.cc b/libtransmission/watchdir-inotify.cc index b297a359f..889c27bf8 100644 --- a/libtransmission/watchdir-inotify.cc +++ b/libtransmission/watchdir-inotify.cc @@ -83,7 +83,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -95,7 +95,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -107,7 +107,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -139,7 +139,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't read event: {error} ({error_code})"), + fmt::runtime(_("Couldn't read event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); break; @@ -148,7 +148,7 @@ private: if (nread != sizeof(ev)) { tr_logAddError(fmt::format( - _("Couldn't read event: expected {expected_size}, got {actual_size}"), + fmt::runtime(_("Couldn't read event: expected {expected_size}, got {actual_size}")), fmt::arg("expected_size", sizeof(ev)), fmt::arg("actual_size", nread))); break; @@ -165,7 +165,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't read filename: {error} ({error_code})"), + fmt::runtime(_("Couldn't read filename: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); break; @@ -174,7 +174,7 @@ private: if (nread != ev.len) { tr_logAddError(fmt::format( - _("Couldn't read filename: expected {expected_size}, got {actual_size}"), + fmt::runtime(_("Couldn't read filename: expected {expected_size}, got {actual_size}")), fmt::arg("expected_size", sizeof(ev)), fmt::arg("actual_size", nread))); break; diff --git a/libtransmission/watchdir-kqueue.cc b/libtransmission/watchdir-kqueue.cc index ca10f3051..ac726792b 100644 --- a/libtransmission/watchdir-kqueue.cc +++ b/libtransmission/watchdir-kqueue.cc @@ -72,7 +72,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); return; @@ -85,7 +85,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -100,7 +100,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't watch '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't watch '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); @@ -113,7 +113,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't create event: {error} ({error_code})"), + fmt::runtime(_("Couldn't create event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); return; @@ -123,7 +123,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't add event: {error} ({error_code})"), + fmt::runtime(_("Couldn't add event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); return; @@ -143,7 +143,7 @@ private: { auto const error_code = errno; tr_logAddError(fmt::format( - _("Couldn't read event: {error} ({error_code})"), + fmt::runtime(_("Couldn't read event: {error} ({error_code})")), fmt::arg("error", tr_strerror(error_code)), fmt::arg("error_code", error_code))); return; diff --git a/libtransmission/watchdir.cc b/libtransmission/watchdir.cc index cc1dddac1..760d36659 100644 --- a/libtransmission/watchdir.cc +++ b/libtransmission/watchdir.cc @@ -49,7 +49,7 @@ namespace if (error && !tr_error_is_enoent(error.code())) { tr_logAddWarn(fmt::format( - _("Skipping '{path}': {error} ({error_code})"), + fmt::runtime(_("Skipping '{path}': {error} ({error_code})")), fmt::arg("path", path), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); @@ -88,7 +88,7 @@ void BaseWatchdir::processFile(std::string_view basename) if (now - info.first_kick_at > timeoutDuration()) { - tr_logAddWarn(fmt::format(_("Couldn't add torrent file '{path}'"), fmt::arg("path", basename))); + tr_logAddWarn(fmt::format(fmt::runtime(_("Couldn't add torrent file '{path}'")), fmt::arg("path", basename))); pending_.erase(iter); } else @@ -115,7 +115,7 @@ void BaseWatchdir::scan() if (error) { tr_logAddWarn(fmt::format( - _("Couldn't read '{path}': {error} ({error_code})"), + fmt::runtime(_("Couldn't read '{path}': {error} ({error_code})")), fmt::arg("path", dirname()), fmt::arg("error", error.message()), fmt::arg("error_code", error.code()))); diff --git a/libtransmission/web.cc b/libtransmission/web.cc index 4bb3efd7a..303832f44 100644 --- a/libtransmission/web.cc +++ b/libtransmission/web.cc @@ -193,8 +193,9 @@ public: if (curl_ssl_verify) { auto const* bundle = std::empty(curl_ca_bundle) ? "none" : curl_ca_bundle.c_str(); - tr_logAddInfo( - fmt::format(_("Will verify tracker certs using envvar CURL_CA_BUNDLE: {bundle}"), fmt::arg("bundle", bundle))); + tr_logAddInfo(fmt::format( + fmt::runtime(_("Will verify tracker certs using envvar CURL_CA_BUNDLE: {bundle}")), + fmt::arg("bundle", bundle))); tr_logAddInfo(_("NB: this only works if you built against libcurl with openssl or gnutls, NOT nss")); tr_logAddInfo(_("NB: Invalid certs will appear as 'Could not connect to tracker' like many other errors")); } @@ -493,7 +494,7 @@ public: if (code != NoResponseCode && code != PartialContentResponseCode) { tr_logAddWarn(fmt::format( - _("Couldn't fetch '{url}': expected HTTP response code {expected_code}, got {actual_code}"), + fmt::runtime(_("Couldn't fetch '{url}': expected HTTP response code {expected_code}, got {actual_code}")), fmt::arg("url", task->url()), fmt::arg("expected_code", PartialContentResponseCode), fmt::arg("actual_code", code))); diff --git a/utils/create.cc b/utils/create.cc index f2871cca4..52bbaa34e 100644 --- a/utils/create.cc +++ b/utils/create.cc @@ -232,15 +232,16 @@ int tr_main(int argc, char* argv[]) } fmt::print( - tr_ngettext("{file_count:L} file, {total_size}\n", "{file_count:L} files, {total_size}\n", builder.file_count()), + fmt::runtime( + tr_ngettext("{file_count:L} file, {total_size}\n", "{file_count:L} files, {total_size}\n", builder.file_count())), fmt::arg("file_count", builder.file_count()), fmt::arg("total_size", Storage{ builder.total_size(), Storage::Units::Bytes }.to_string())); fmt::print( - tr_ngettext( + fmt::runtime(tr_ngettext( "{piece_count:L} piece, {piece_size}\n", "{piece_count:L} pieces, {piece_size} each\n", - builder.piece_count()), + builder.piece_count())), fmt::arg("piece_count", builder.piece_count()), fmt::arg("piece_size", Memory{ builder.piece_size(), Memory::Units::Bytes }.to_string())); diff --git a/utils/remote.cc b/utils/remote.cc index f2dac155b..5f1b2273c 100644 --- a/utils/remote.cc +++ b/utils/remote.cc @@ -935,7 +935,7 @@ void print_details(tr_variant::Map const& map) { if (auto sv = it->value_if(); sv) { - fmt::print(it == begin ? "{:s}" : ", {:s}", *sv); + fmt::print("{:s}{:s}", it == begin ? ", " : "", *sv); } }