Improve pacman.c gettext usage

* Break out a few strings in pacman.c that are used repeatedly to
  reduce unnecessary translations.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2007-03-27 20:26:54 -04:00
parent a2a781f416
commit 5ec3ed4674

View file

@ -21,6 +21,7 @@
#include "config.h" #include "config.h"
/* TODO hard to believe all these are needed just for this file */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <limits.h> #include <limits.h>
@ -86,25 +87,34 @@ static alpm_list_t *pm_targets;
*/ */
static void usage(int op, char *myname) static void usage(int op, char *myname)
{ {
/* prefetch some strings for usage below, which moves a lot of calls
* out of gettext. */
char * const str_opt = _("options");
char * const str_file = _("file");
char * const str_pkg = _("package");
char * const str_usg = _("usage");
if(op == PM_OP_MAIN) { if(op == PM_OP_MAIN) {
printf(_("usage: %s {-h --help}\n"), myname); printf("%s:", str_usg);
printf(_(" %s {-V --version}\n"), myname); printf(" %s {-h --help}\n", myname);
printf(_(" %s {-A --add} [options] <file>\n"), myname); printf(" %s {-V --version}\n", myname);
printf(_(" %s {-F --freshen} [options] <file>\n"), myname); printf(" %s {-A --add} [%s] <%s>\n", myname, str_opt, str_file);
printf(_(" %s {-Q --query} [options] [package]\n"), myname); printf(" %s {-F --freshen} [%s] <%s>\n", myname, str_opt, str_file);
printf(_(" %s {-R --remove} [options] <package>\n"), myname); printf(" %s {-Q --query} [%s] [%s]\n", myname, str_opt, str_pkg);
printf(_(" %s {-S --sync} [options] [package]\n"), myname); printf(" %s {-R --remove} [%s] <%s>\n", myname, str_opt, str_pkg);
printf(_(" %s {-U --upgrade} [options] <file>\n"), myname); printf(" %s {-S --sync} [%s] [%s]\n", myname, str_opt, str_pkg);
printf(" %s {-U --upgrade} [%s] <%s>\n", myname, str_opt, str_file);
printf(_("\nuse '%s --help' with other options for more syntax\n"), myname); printf(_("\nuse '%s --help' with other options for more syntax\n"), myname);
} else { } else {
if(op == PM_OP_ADD) { if(op == PM_OP_ADD) {
printf(_("usage: %s {-A --add} [options] <file>\n"), myname); printf("%s: %s {-A --add} [%s] <%s>\n", str_usg, myname, str_opt, str_file);
printf(_("options:\n")); printf("%s:\n", str_opt);
printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -d, --nodeps skip dependency checks\n"));
printf(_(" -f, --force force install, overwrite conflicting files\n")); printf(_(" -f, --force force install, overwrite conflicting files\n"));
} else if(op == PM_OP_REMOVE) { } else if(op == PM_OP_REMOVE) {
printf("%s: %s {-R --remove} [%s] <%s>\n", str_usg, myname, str_opt, str_pkg);
printf(_("usage: %s {-R --remove} [options] <package>\n"), myname); printf(_("usage: %s {-R --remove} [options] <package>\n"), myname);
printf(_("options:\n")); printf("%s:\n", str_opt);
printf(_(" -c, --cascade remove packages and all packages that depend on them\n")); printf(_(" -c, --cascade remove packages and all packages that depend on them\n"));
printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -d, --nodeps skip dependency checks\n"));
printf(_(" -k, --dbonly only remove database entry, do not remove files\n")); printf(_(" -k, --dbonly only remove database entry, do not remove files\n"));
@ -112,19 +122,19 @@ static void usage(int op, char *myname)
printf(_(" -s, --recursive remove dependencies also (that won't break packages)\n")); printf(_(" -s, --recursive remove dependencies also (that won't break packages)\n"));
} else if(op == PM_OP_UPGRADE) { } else if(op == PM_OP_UPGRADE) {
if(config->flags & PM_TRANS_FLAG_FRESHEN) { if(config->flags & PM_TRANS_FLAG_FRESHEN) {
printf(_("usage: %s {-F --freshen} [options] <file>\n"), myname); printf("%s: %s {-F --freshen} [%s] <%s>\n", str_usg, myname, str_opt, str_file);
} else { } else {
printf(_("usage: %s {-U --upgrade} [options] <file>\n"), myname); printf("%s: %s {-U --upgrade} [%s] <%s>\n", str_usg, myname, str_opt, str_file);
} }
printf(_("options:\n")); printf("%s:\n", str_opt);
printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -d, --nodeps skip dependency checks\n"));
printf(_(" -f, --force force install, overwrite conflicting files\n")); printf(_(" -f, --force force install, overwrite conflicting files\n"));
} else if(op == PM_OP_QUERY) { } else if(op == PM_OP_QUERY) {
printf(_("usage: %s {-Q --query} [options] [package]\n"), myname); printf("%s: %s {-Q --query} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
printf(_("options:\n")); printf("%s:\n", str_opt);
printf(_(" -c, --changelog view the changelog of a package\n")); printf(_(" -c, --changelog view the changelog of a package\n"));
printf(_(" -e, --orphans list all packages installed as dependencies but no longer\n")); printf(_(" -e, --orphans list all packages installed as dependencies but no longer\n"
printf(_(" required by any package\n")); " required by any package\n"));
printf(_(" -g, --groups view all members of a package group\n")); printf(_(" -g, --groups view all members of a package group\n"));
printf(_(" -i, --info view package information\n")); printf(_(" -i, --info view package information\n"));
printf(_(" -l, --list list the contents of the queried package\n")); printf(_(" -l, --list list the contents of the queried package\n"));
@ -134,8 +144,8 @@ static void usage(int op, char *myname)
printf(_(" -s, --search <regex> search locally-installed packages for matching strings\n")); printf(_(" -s, --search <regex> search locally-installed packages for matching strings\n"));
printf(_(" -u, --upgrades list all packages that can be upgraded\n")); printf(_(" -u, --upgrades list all packages that can be upgraded\n"));
} else if(op == PM_OP_SYNC) { } else if(op == PM_OP_SYNC) {
printf(_("usage: %s {-S --sync} [options] [package]\n"), myname); printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
printf(_("options:\n")); printf("%s:\n", str_opt);
printf(_(" -c, --clean remove old packages from cache directory (-cc for all)\n")); printf(_(" -c, --clean remove old packages from cache directory (-cc for all)\n"));
printf(_(" -d, --nodeps skip dependency checks\n")); printf(_(" -d, --nodeps skip dependency checks\n"));
printf(_(" -e, --dependsonly install dependencies only\n")); printf(_(" -e, --dependsonly install dependencies only\n"));
@ -154,7 +164,7 @@ static void usage(int op, char *myname)
printf(_(" --noconfirm do not ask for any confirmation\n")); printf(_(" --noconfirm do not ask for any confirmation\n"));
printf(_(" --ask <number> pre-specify answers for questions (see manpage)\n")); printf(_(" --ask <number> pre-specify answers for questions (see manpage)\n"));
printf(_(" --noprogressbar do not show a progress bar when downloading files\n")); printf(_(" --noprogressbar do not show a progress bar when downloading files\n"));
printf(_(" --noscriptlet do not execute the install scriptlet if there is any\n")); printf(_(" --noscriptlet do not execute the install scriptlet if one exists\n"));
printf(_(" -v, --verbose be verbose\n")); printf(_(" -v, --verbose be verbose\n"));
printf(_(" -r, --root <path> set an alternate installation root\n")); printf(_(" -r, --root <path> set an alternate installation root\n"));
printf(_(" -b, --dbpath <path> set an alternate database location\n")); printf(_(" -b, --dbpath <path> set an alternate database location\n"));
@ -171,8 +181,8 @@ static void version()
printf("/ _.-' .-. .-. .-. Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>\n"); printf("/ _.-' .-. .-. .-. Copyright (C) 2002-2007 Judd Vinet <jvinet@zeroflux.org>\n");
printf("\\ '-. '-' '-' '-'\n"); printf("\\ '-. '-' '-' '-'\n");
printf(" '--'\n"); printf(" '--'\n");
printf(_(" This program may be freely redistributed under\n")); printf(_(" This program may be freely redistributed under\n"
printf(_(" the terms of the GNU General Public License\n")); " the terms of the GNU General Public License\n"));
printf("\n"); printf("\n");
} }