From 0130265742fb2c1c28e335358ae48a013e6510e1 Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Thu, 3 Oct 2024 06:05:46 +0900 Subject: [PATCH] Make most descriptions for dnf5 --help translatable. Use _(msgId) in bgettext-lib.h to mark text as eligible for translation. This will allow translators to translate the short descriptions of the commands in dnf5 --help. Further changes will be required to make each command description translatable. Related: #1736 --- dnf5-plugins/config-manager_plugin/config-manager.cpp | 4 +++- dnf5/commands/advisory/advisory.cpp | 2 +- dnf5/commands/autoremove/autoremove.cpp | 2 +- dnf5/commands/check-upgrade/check-upgrade.cpp | 2 +- dnf5/commands/check/check.cpp | 2 +- dnf5/commands/debuginfo-install/debuginfo-install.cpp | 2 +- dnf5/commands/distro-sync/distro-sync.cpp | 3 ++- dnf5/commands/downgrade/downgrade.cpp | 2 +- dnf5/commands/environment/environment.cpp | 2 +- dnf5/commands/history/history.cpp | 2 +- dnf5/commands/install/install.cpp | 2 +- dnf5/commands/leaves/leaves.cpp | 3 ++- dnf5/commands/mark/mark.cpp | 2 +- dnf5/commands/module/module.cpp | 2 +- dnf5/commands/provides/provides.cpp | 3 ++- dnf5/commands/reinstall/reinstall.cpp | 2 +- dnf5/commands/remove/remove.cpp | 2 +- dnf5/commands/replay/replay.cpp | 2 +- dnf5/commands/repo/repo.cpp | 3 ++- dnf5/commands/repoquery/repoquery.cpp | 2 +- dnf5/commands/search/search.cpp | 2 +- dnf5/commands/swap/swap.cpp | 2 +- dnf5/commands/upgrade/upgrade.cpp | 2 +- dnf5/commands/versionlock/versionlock.cpp | 4 +++- dnf5/main.cpp | 6 +++--- dnf5daemon-client/commands/advisory/advisory.cpp | 2 +- dnf5daemon-client/commands/distro-sync/distro-sync.cpp | 3 ++- dnf5daemon-client/commands/group/group.cpp | 2 +- dnf5daemon-client/commands/repo/repo.cpp | 4 +++- dnf5daemon-client/commands/repoquery/repoquery.cpp | 3 ++- 30 files changed, 44 insertions(+), 32 deletions(-) diff --git a/dnf5-plugins/config-manager_plugin/config-manager.cpp b/dnf5-plugins/config-manager_plugin/config-manager.cpp index e8039bfaa..a9019f5f6 100644 --- a/dnf5-plugins/config-manager_plugin/config-manager.cpp +++ b/dnf5-plugins/config-manager_plugin/config-manager.cpp @@ -25,6 +25,8 @@ along with libdnf. If not, see . #include "unsetopt.hpp" #include "unsetvar.hpp" +#include + namespace dnf5 { using namespace libdnf5::cli; @@ -38,7 +40,7 @@ void ConfigManagerCommand::set_parent_command() { void ConfigManagerCommand::set_argument_parser() { auto & cmd = *get_argument_parser_command(); - cmd.set_description("Manage configuration"); + cmd.set_description(_("Manage configuration")); cmd.set_long_description("Manage main and repositories configuration, variables and add new repositories."); } diff --git a/dnf5/commands/advisory/advisory.cpp b/dnf5/commands/advisory/advisory.cpp index 155fbc873..a87b50551 100644 --- a/dnf5/commands/advisory/advisory.cpp +++ b/dnf5/commands/advisory/advisory.cpp @@ -33,7 +33,7 @@ void AdvisoryCommand::set_parent_command() { } void AdvisoryCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage advisories"); + get_argument_parser_command()->set_description(_("Manage advisories")); } void AdvisoryCommand::register_subcommands() { diff --git a/dnf5/commands/autoremove/autoremove.cpp b/dnf5/commands/autoremove/autoremove.cpp index 0e879b956..6ad709547 100644 --- a/dnf5/commands/autoremove/autoremove.cpp +++ b/dnf5/commands/autoremove/autoremove.cpp @@ -35,7 +35,7 @@ void AutoremoveCommand::set_parent_command() { void AutoremoveCommand::set_argument_parser() { get_argument_parser_command()->set_description( - "Remove all unneeded packages originally installed as dependencies."); + _("Remove all unneeded packages originally installed as dependencies.")); create_offline_option(*this); create_store_option(*this); } diff --git a/dnf5/commands/check-upgrade/check-upgrade.cpp b/dnf5/commands/check-upgrade/check-upgrade.cpp index 60aac098f..2b241d4b2 100644 --- a/dnf5/commands/check-upgrade/check-upgrade.cpp +++ b/dnf5/commands/check-upgrade/check-upgrade.cpp @@ -44,7 +44,7 @@ void CheckUpgradeCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Check for available package upgrades"); + cmd.set_description(_("Check for available package upgrades")); minimal = dynamic_cast( parser.add_init_value(std::unique_ptr(new libdnf5::OptionBool(false)))); diff --git a/dnf5/commands/check/check.cpp b/dnf5/commands/check/check.cpp index 3d22713c0..51de732dd 100644 --- a/dnf5/commands/check/check.cpp +++ b/dnf5/commands/check/check.cpp @@ -244,7 +244,7 @@ void CheckCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Check for problems in the packagedb"); + cmd.set_description(_("Check for problems in the packagedb")); cmd.set_long_description( "Checks the local packagedb and produces information on any problems it finds.\n" "The set of checks performed can be specified with options."); diff --git a/dnf5/commands/debuginfo-install/debuginfo-install.cpp b/dnf5/commands/debuginfo-install/debuginfo-install.cpp index 6dee2887b..abda2563d 100644 --- a/dnf5/commands/debuginfo-install/debuginfo-install.cpp +++ b/dnf5/commands/debuginfo-install/debuginfo-install.cpp @@ -42,7 +42,7 @@ void DebuginfoInstallCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - get_argument_parser_command()->set_description("Install debuginfo packages."); + get_argument_parser_command()->set_description(_("Install debuginfo packages.")); allow_erasing = std::make_unique(*this); auto skip_broken = std::make_unique(*this); diff --git a/dnf5/commands/distro-sync/distro-sync.cpp b/dnf5/commands/distro-sync/distro-sync.cpp index 534c95f98..2fee8f824 100644 --- a/dnf5/commands/distro-sync/distro-sync.cpp +++ b/dnf5/commands/distro-sync/distro-sync.cpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #include #include +#include namespace dnf5 { @@ -38,7 +39,7 @@ void DistroSyncCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Upgrade or downgrade installed software to the latest available versions"); + cmd.set_description(_("Upgrade or downgrade installed software to the latest available versions")); patterns_to_distro_sync_options = parser.add_new_values(); auto patterns_arg = parser.add_new_positional_arg( diff --git a/dnf5/commands/downgrade/downgrade.cpp b/dnf5/commands/downgrade/downgrade.cpp index 071b3dc45..6fa3b6d3a 100644 --- a/dnf5/commands/downgrade/downgrade.cpp +++ b/dnf5/commands/downgrade/downgrade.cpp @@ -37,7 +37,7 @@ void DowngradeCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Downgrade software"); + cmd.set_description(_("Downgrade software")); auto keys = parser.add_new_positional_arg("spec", ArgumentParser::PositionalArg::AT_LEAST_ONE, nullptr, nullptr); keys->set_description("List of package specs to downgrade"); diff --git a/dnf5/commands/environment/environment.cpp b/dnf5/commands/environment/environment.cpp index b81af2093..7c6adf297 100644 --- a/dnf5/commands/environment/environment.cpp +++ b/dnf5/commands/environment/environment.cpp @@ -32,7 +32,7 @@ void EnvironmentCommand::set_parent_command() { } void EnvironmentCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage comps environments"); + get_argument_parser_command()->set_description(_("Manage comps environments")); } void EnvironmentCommand::register_subcommands() { diff --git a/dnf5/commands/history/history.cpp b/dnf5/commands/history/history.cpp index 3d86d0367..21f98be90 100644 --- a/dnf5/commands/history/history.cpp +++ b/dnf5/commands/history/history.cpp @@ -38,7 +38,7 @@ void HistoryCommand::set_parent_command() { } void HistoryCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage transaction history"); + get_argument_parser_command()->set_description(_("Manage transaction history")); } void HistoryCommand::register_subcommands() { diff --git a/dnf5/commands/install/install.cpp b/dnf5/commands/install/install.cpp index 04b66723d..e8d198650 100644 --- a/dnf5/commands/install/install.cpp +++ b/dnf5/commands/install/install.cpp @@ -38,7 +38,7 @@ void InstallCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Install software"); + cmd.set_description(_("Install software")); auto keys = parser.add_new_positional_arg("specs", ArgumentParser::PositionalArg::AT_LEAST_ONE, nullptr, nullptr); keys->set_description("List of |@|@ to install"); diff --git a/dnf5/commands/leaves/leaves.cpp b/dnf5/commands/leaves/leaves.cpp index ede2db69a..93cfdaff0 100644 --- a/dnf5/commands/leaves/leaves.cpp +++ b/dnf5/commands/leaves/leaves.cpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #include #include #include +#include #include @@ -38,7 +39,7 @@ void LeavesCommand::set_parent_command() { void LeavesCommand::set_argument_parser() { get_argument_parser_command()->set_description( - "List groups of installed packages not required by other installed packages"); + _("List groups of installed packages not required by other installed packages")); get_argument_parser_command()->set_long_description( R"(The `leaves` command is used to list all leaf packages. diff --git a/dnf5/commands/mark/mark.cpp b/dnf5/commands/mark/mark.cpp index da4b535f6..26c6358fe 100644 --- a/dnf5/commands/mark/mark.cpp +++ b/dnf5/commands/mark/mark.cpp @@ -35,7 +35,7 @@ void MarkCommand::set_parent_command() { } void MarkCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Change the reason of an installed package"); + get_argument_parser_command()->set_description(_("Change the reason of an installed package")); auto skip_unavailable = std::make_unique(*this); create_store_option(*this); } diff --git a/dnf5/commands/module/module.cpp b/dnf5/commands/module/module.cpp index a6438f973..0db4a45c5 100644 --- a/dnf5/commands/module/module.cpp +++ b/dnf5/commands/module/module.cpp @@ -40,7 +40,7 @@ void ModuleCommand::set_parent_command() { } void ModuleCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage modules"); + get_argument_parser_command()->set_description(_("Manage modules")); } void ModuleCommand::register_subcommands() { diff --git a/dnf5/commands/provides/provides.cpp b/dnf5/commands/provides/provides.cpp index bb8e22148..716ee8145 100644 --- a/dnf5/commands/provides/provides.cpp +++ b/dnf5/commands/provides/provides.cpp @@ -25,6 +25,7 @@ along with libdnf. If not, see . #include #include #include +#include #include @@ -44,7 +45,7 @@ void ProvidesCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Find what package provides the given value"); + cmd.set_description(_("Find what package provides the given value")); auto * keys = parser.add_new_positional_arg("specs", ArgumentParser::PositionalArg::AT_LEAST_ONE, nullptr, nullptr); keys->set_description("List of package specs to query"); diff --git a/dnf5/commands/reinstall/reinstall.cpp b/dnf5/commands/reinstall/reinstall.cpp index 1b64b7530..7ac214814 100644 --- a/dnf5/commands/reinstall/reinstall.cpp +++ b/dnf5/commands/reinstall/reinstall.cpp @@ -37,7 +37,7 @@ void ReinstallCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Reinstall software"); + cmd.set_description(_("Reinstall software")); auto keys = parser.add_new_positional_arg("specs", ArgumentParser::PositionalArg::AT_LEAST_ONE, nullptr, nullptr); keys->set_description("List of package specs to reinstall"); diff --git a/dnf5/commands/remove/remove.cpp b/dnf5/commands/remove/remove.cpp index 4d00431f9..a14669b51 100644 --- a/dnf5/commands/remove/remove.cpp +++ b/dnf5/commands/remove/remove.cpp @@ -37,7 +37,7 @@ void RemoveCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Remove (uninstall) software"); + cmd.set_description(_("Remove (uninstall) software")); auto noautoremove = parser.add_new_named_arg("no-autoremove"); noautoremove->set_long_name("no-autoremove"); diff --git a/dnf5/commands/replay/replay.cpp b/dnf5/commands/replay/replay.cpp index 8b71984c3..cfebc0505 100644 --- a/dnf5/commands/replay/replay.cpp +++ b/dnf5/commands/replay/replay.cpp @@ -35,7 +35,7 @@ void ReplayCommand::set_parent_command() { void ReplayCommand::set_argument_parser() { auto & cmd = *get_argument_parser_command(); - cmd.set_description("Replay a transaction that was previously stored to a directory"); + cmd.set_description(_("Replay a transaction that was previously stored to a directory")); auto & ctx = get_context(); auto & parser = ctx.get_argument_parser(); diff --git a/dnf5/commands/repo/repo.cpp b/dnf5/commands/repo/repo.cpp index bd1ac8492..d6ef6d60e 100644 --- a/dnf5/commands/repo/repo.cpp +++ b/dnf5/commands/repo/repo.cpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "repo_list.hpp" #include +#include namespace dnf5 { @@ -34,7 +35,7 @@ void RepoCommand::set_parent_command() { } void RepoCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage repositories"); + get_argument_parser_command()->set_description(_("Manage repositories")); } void RepoCommand::register_subcommands() { diff --git a/dnf5/commands/repoquery/repoquery.cpp b/dnf5/commands/repoquery/repoquery.cpp index 10a53fd5c..fbfc7f200 100644 --- a/dnf5/commands/repoquery/repoquery.cpp +++ b/dnf5/commands/repoquery/repoquery.cpp @@ -77,7 +77,7 @@ void RepoqueryCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Search for packages matching various criteria"); + cmd.set_description(_("Search for packages matching various criteria")); // OPTION GROUPS diff --git a/dnf5/commands/search/search.cpp b/dnf5/commands/search/search.cpp index 0ba270b5a..4d762804e 100644 --- a/dnf5/commands/search/search.cpp +++ b/dnf5/commands/search/search.cpp @@ -41,7 +41,7 @@ void SearchCommand::set_parent_command() { void SearchCommand::set_argument_parser() { auto & cmd = *get_argument_parser_command(); - cmd.set_description("Search for software matching all specified strings"); + cmd.set_description(_("Search for software matching all specified strings")); all = std::make_unique(*this); patterns = std::make_unique(*this, get_context()); diff --git a/dnf5/commands/swap/swap.cpp b/dnf5/commands/swap/swap.cpp index 4aaf9ec24..c14caa03b 100644 --- a/dnf5/commands/swap/swap.cpp +++ b/dnf5/commands/swap/swap.cpp @@ -39,7 +39,7 @@ void SwapCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Remove software and install another in one transaction"); + cmd.set_description(_("Remove software and install another in one transaction")); auto remove_spec_arg = parser.add_new_positional_arg("remove_spec", 1, nullptr, nullptr); remove_spec_arg->set_description("The spec that will be removed"); diff --git a/dnf5/commands/upgrade/upgrade.cpp b/dnf5/commands/upgrade/upgrade.cpp index cd9728292..c46613e31 100644 --- a/dnf5/commands/upgrade/upgrade.cpp +++ b/dnf5/commands/upgrade/upgrade.cpp @@ -38,7 +38,7 @@ void UpgradeCommand::set_argument_parser() { auto & parser = ctx.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Upgrade software"); + cmd.set_description(_("Upgrade software")); minimal = dynamic_cast( parser.add_init_value(std::unique_ptr(new libdnf5::OptionBool(false)))); diff --git a/dnf5/commands/versionlock/versionlock.cpp b/dnf5/commands/versionlock/versionlock.cpp index bcf54f081..cdddf309f 100644 --- a/dnf5/commands/versionlock/versionlock.cpp +++ b/dnf5/commands/versionlock/versionlock.cpp @@ -25,6 +25,8 @@ along with libdnf. If not, see . #include "versionlock_exclude.hpp" #include "versionlock_list.hpp" +#include + namespace dnf5 { void VersionlockCommand::set_parent_command() { @@ -35,7 +37,7 @@ void VersionlockCommand::set_parent_command() { } void VersionlockCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage versionlock configuration"); + get_argument_parser_command()->set_description(_("Manage versionlock configuration")); } void VersionlockCommand::register_subcommands() { diff --git a/dnf5/main.cpp b/dnf5/main.cpp index 314cc0e86..7c454051e 100644 --- a/dnf5/main.cpp +++ b/dnf5/main.cpp @@ -266,7 +266,7 @@ void RootCommand::set_argument_parser() { setvar->set_long_name("setvar"); setvar->set_has_value(true); setvar->set_arg_value_help("VAR_NAME=VALUE"); - setvar->set_description("set arbitrary variable"); + setvar->set_description(_("set arbitrary variable")); setvar->set_parse_hook_func( [&ctx]( [[maybe_unused]] ArgumentParser::NamedArg * arg, [[maybe_unused]] const char * option, const char * value) { @@ -303,7 +303,7 @@ void RootCommand::set_argument_parser() { auto best = parser.add_new_named_arg("best"); best->set_long_name("best"); - best->set_description(("try the best available package versions in transactions")); + best->set_description(_("try the best available package versions in transactions")); best->set_const_value("true"); best->link_value(&config.get_best_option()); global_options_group->register_argument(best); @@ -430,7 +430,7 @@ void RootCommand::set_argument_parser() { auto no_plugins = parser.add_new_named_arg("no-plugins"); no_plugins->set_long_name("no-plugins"); - no_plugins->set_description("Disable all libdnf5 plugins"); + no_plugins->set_description(_("Disable all libdnf5 plugins")); no_plugins->set_const_value("false"); no_plugins->link_value(&config.get_plugins_option()); global_options_group->register_argument(no_plugins); diff --git a/dnf5daemon-client/commands/advisory/advisory.cpp b/dnf5daemon-client/commands/advisory/advisory.cpp index 09d5dede9..f40b85c60 100644 --- a/dnf5daemon-client/commands/advisory/advisory.cpp +++ b/dnf5daemon-client/commands/advisory/advisory.cpp @@ -32,7 +32,7 @@ void AdvisoryCommand::set_parent_command() { } void AdvisoryCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage advisories"); + get_argument_parser_command()->set_description(_("Manage advisories")); } void AdvisoryCommand::register_subcommands() { diff --git a/dnf5daemon-client/commands/distro-sync/distro-sync.cpp b/dnf5daemon-client/commands/distro-sync/distro-sync.cpp index 8b1d0741c..c9b95c5cf 100644 --- a/dnf5daemon-client/commands/distro-sync/distro-sync.cpp +++ b/dnf5daemon-client/commands/distro-sync/distro-sync.cpp @@ -26,6 +26,7 @@ along with libdnf. If not, see . #include #include +#include #include @@ -44,7 +45,7 @@ void DistroSyncCommand::set_argument_parser() { auto & parser = get_context().get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Upgrade or downgrade installed software to the latest available versions"); + cmd.set_description(_("Upgrade or downgrade installed software to the latest available versions")); auto specs_arg = pkg_specs_argument(parser, libdnf5::cli::ArgumentParser::PositionalArg::UNLIMITED, pkg_specs); specs_arg->set_description("Patterns"); diff --git a/dnf5daemon-client/commands/group/group.cpp b/dnf5daemon-client/commands/group/group.cpp index 4b2e56a66..c41c3356d 100644 --- a/dnf5daemon-client/commands/group/group.cpp +++ b/dnf5daemon-client/commands/group/group.cpp @@ -38,7 +38,7 @@ void GroupCommand::set_argument_parser() { auto & parser = context.get_argument_parser(); auto & cmd = *get_argument_parser_command(); - cmd.set_description("Manage comps groups"); + cmd.set_description(_("Manage comps groups")); // query commands auto * query_commands_group = parser.add_new_group("group_query_commands"); diff --git a/dnf5daemon-client/commands/repo/repo.cpp b/dnf5daemon-client/commands/repo/repo.cpp index 56c671346..8dd123469 100644 --- a/dnf5daemon-client/commands/repo/repo.cpp +++ b/dnf5daemon-client/commands/repo/repo.cpp @@ -22,6 +22,8 @@ along with libdnf. If not, see . #include "repo_disable.hpp" #include "repo_enable.hpp" +#include + namespace dnfdaemon::client { void RepoCommand::set_parent_command() { @@ -32,7 +34,7 @@ void RepoCommand::set_parent_command() { } void RepoCommand::set_argument_parser() { - get_argument_parser_command()->set_description("Manage repositories"); + get_argument_parser_command()->set_description(_("Manage repositories")); } void RepoCommand::register_subcommands() { diff --git a/dnf5daemon-client/commands/repoquery/repoquery.cpp b/dnf5daemon-client/commands/repoquery/repoquery.cpp index ec89e1779..10d39e89c 100644 --- a/dnf5daemon-client/commands/repoquery/repoquery.cpp +++ b/dnf5daemon-client/commands/repoquery/repoquery.cpp @@ -33,6 +33,7 @@ along with libdnf. If not, see . #include #include #include +#include #include #include #include @@ -91,7 +92,7 @@ void RepoqueryCommand::set_argument_parser() { patterns_options); keys->set_description("List of keys to match"); - cmd.set_description("search for packages matching various criteria"); + cmd.set_description(_("search for packages matching various criteria")); cmd.register_named_arg(available); cmd.register_named_arg(installed);