Skip to content

Commit

Permalink
I18N: Mark messages in "dnf info" output for a translation
Browse files Browse the repository at this point in the history
Related: #1687
  • Loading branch information
ppisar committed Sep 16, 2024
1 parent 3b64925 commit 2610a58
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
18 changes: 9 additions & 9 deletions dnf5/commands/list/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -205,15 +205,15 @@ 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:
base_query.filter_priority();
base_query.filter_upgrades();
base_query.filter_arch(std::vector<std::string>{"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();
Expand All @@ -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();
Expand All @@ -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;
}

Expand Down
37 changes: 20 additions & 17 deletions libdnf5-cli/output/packageinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ 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, " : ");
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());
Expand All @@ -79,29 +79,32 @@ void print_package_info(

if (!pkg.is_installed()) {
add_line(
table, "Download size", utils::units::format_size_aligned(static_cast<int64_t>(pkg.get_download_size())));
table,
_("Download size"),
utils::units::format_size_aligned(static_cast<int64_t>(pkg.get_download_size())));
}
add_line(table, "Installed size", utils::units::format_size_aligned(static_cast<int64_t>(pkg.get_install_size())));
add_line(
table, _("Installed size"), utils::units::format_size_aligned(static_cast<int64_t>(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);
Expand Down

0 comments on commit 2610a58

Please sign in to comment.