From 67b1fb2446c98ab1ec2c727ee32d852271baa2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Fri, 13 Sep 2024 17:01:20 +0200 Subject: [PATCH] I18N: Mark messages in "dnf info" output for a translation Related: https://github.com/rpm-software-management/dnf5/issues/1687 --- dnf5/commands/list/list.cpp | 18 +++++++------- libdnf5-cli/output/packageinfo.cpp | 39 +++++++++++++++++------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/dnf5/commands/list/list.cpp b/dnf5/commands/list/list.cpp index 16839a621..72221c243 100644 --- a/dnf5/commands/list/list.cpp +++ b/dnf5/commands/list/list.cpp @@ -191,12 +191,12 @@ void ListCommand::run() { installed_latest.filter_latest_evr(); available.filter_nevra(installed_latest, libdnf5::sack::QueryCmp::NOT | libdnf5::sack::QueryCmp::LTE); } - package_matched |= sections->add_section("Installed packages", installed); - package_matched |= sections->add_section("Available packages", available); + package_matched |= sections->add_section(_("Installed packages"), installed); + package_matched |= sections->add_section(_("Available packages"), available); break; } case PkgNarrow::INSTALLED: { - package_matched |= sections->add_section("Installed packages", installed); + package_matched |= sections->add_section(_("Installed packages"), installed); break; } case PkgNarrow::AVAILABLE: { @@ -205,7 +205,7 @@ void ListCommand::run() { base_query.filter_priority(); base_query.filter_latest_evr(); } - package_matched |= sections->add_section("Available packages", base_query); + package_matched |= sections->add_section(_("Available packages"), base_query); break; } case PkgNarrow::UPGRADES: @@ -213,7 +213,7 @@ void ListCommand::run() { base_query.filter_upgrades(); base_query.filter_arch(std::vector{"src", "nosrc"}, libdnf5::sack::QueryCmp::NEQ); base_query.filter_latest_evr(); - package_matched |= sections->add_section("Available upgrades", base_query); + package_matched |= sections->add_section(_("Available upgrades"), base_query); break; case PkgNarrow::OBSOLETES: { base_query.filter_priority(); @@ -229,16 +229,16 @@ void ListCommand::run() { } obsoletes.emplace(pkg.get_id(), obsoleted); } - package_matched |= sections->add_section("Obsoleting packages", base_query, obsoletes); + package_matched |= sections->add_section(_("Obsoleting packages"), base_query, obsoletes); break; } case PkgNarrow::AUTOREMOVE: installed.filter_unneeded(); - package_matched |= sections->add_section("Autoremove packages", installed); + package_matched |= sections->add_section(_("Autoremove packages"), installed); break; case PkgNarrow::EXTRAS: base_query.filter_extras(); - package_matched |= sections->add_section("Extra packages", base_query); + package_matched |= sections->add_section(_("Extra packages"), base_query); break; case PkgNarrow::RECENT: base_query.filter_available(); @@ -249,7 +249,7 @@ void ListCommand::run() { auto recent_limit_days = config.get_recent_option().get_value(); auto now = time(NULL); base_query.filter_recent(now - (recent_limit_days * 86400)); - package_matched |= sections->add_section("Recently added packages", base_query); + package_matched |= sections->add_section(_("Recently added packages"), base_query); break; } diff --git a/libdnf5-cli/output/packageinfo.cpp b/libdnf5-cli/output/packageinfo.cpp index 82ab0bd86..0bc286424 100644 --- a/libdnf5-cli/output/packageinfo.cpp +++ b/libdnf5-cli/output/packageinfo.cpp @@ -52,25 +52,27 @@ void print_package_info( scols_table_enable_noheadings(table, 1); scols_table_new_column(table, "key", 1, 0); scols_table_new_column(table, "value", 1, SCOLS_FL_WRAP); - scols_table_set_column_separator(table, " : "); + // Note for translators: This is a right-aligned column separator in + // a package properties table as in "Name : bash". + scols_table_set_column_separator(table, _(" : ")); if (libdnf5::cli::tty::is_interactive()) { scols_table_enable_colors(table, 1); } // Add package - struct libscols_line * first_line = add_line(table, "Name", pkg.get_name()); + struct libscols_line * first_line = add_line(table, _("Name"), pkg.get_name()); if (colorizer) { scols_line_set_color(first_line, colorizer->get_pkg_color(pkg).c_str()); } - add_line(table, "Epoch", pkg.get_epoch()); - add_line(table, "Version", pkg.get_version()); - add_line(table, "Release", pkg.get_release()); - add_line(table, "Architecture", pkg.get_arch()); + add_line(table, _("Epoch"), pkg.get_epoch()); + add_line(table, _("Version"), pkg.get_version()); + add_line(table, _("Release"), pkg.get_release()); + add_line(table, _("Architecture"), pkg.get_arch()); if (!obsoletes.empty()) { auto iterator = obsoletes.begin(); - add_line(table, "Obsoletes", iterator->get_full_nevra()); + add_line(table, _("Obsoletes"), iterator->get_full_nevra()); ++iterator; for (; iterator != obsoletes.end(); ++iterator) { add_line(table, "", iterator->get_full_nevra()); @@ -79,29 +81,32 @@ void print_package_info( if (!pkg.is_installed()) { add_line( - table, "Download size", utils::units::format_size_aligned(static_cast(pkg.get_download_size()))); + table, + _("Download size"), + utils::units::format_size_aligned(static_cast(pkg.get_download_size()))); } - add_line(table, "Installed size", utils::units::format_size_aligned(static_cast(pkg.get_install_size()))); + add_line( + table, _("Installed size"), utils::units::format_size_aligned(static_cast(pkg.get_install_size()))); if (pkg.get_arch() != "src") { - add_line(table, "Source", pkg.get_sourcerpm()); + add_line(table, _("Source"), pkg.get_sourcerpm()); } if (pkg.is_installed()) { - add_line(table, "From repository", pkg.get_from_repo_id()); + add_line(table, _("From repository"), pkg.get_from_repo_id()); } else { - add_line(table, "Repository", pkg.get_repo_id()); + add_line(table, _("Repository"), pkg.get_repo_id()); } - add_line(table, "Summary", pkg.get_summary()); - add_line(table, "URL", pkg.get_url()); - add_line(table, "License", pkg.get_license()); + add_line(table, _("Summary"), pkg.get_summary()); + add_line(table, _("URL"), pkg.get_url()); + add_line(table, _("License"), pkg.get_license()); auto lines = libdnf5::utils::string::split(pkg.get_description(), "\n"); auto iterator = lines.begin(); - add_line(table, "Description", *iterator); + add_line(table, _("Description"), *iterator); ++iterator; for (; iterator != lines.end(); ++iterator) { add_line(table, "", *iterator); } - add_line(table, "Vendor", pkg.get_vendor()); + add_line(table, _("Vendor"), pkg.get_vendor()); scols_print_table(table); scols_unref_table(table);