diff options
-rw-r--r-- | support/popt.c | 19 | ||||
-rw-r--r-- | support/popthelp.c | 19 | ||||
-rw-r--r-- | support/poptint.h | 18 |
3 files changed, 38 insertions, 18 deletions
diff --git a/support/popt.c b/support/popt.c index ec29c5f..47f0d00 100644 --- a/support/popt.c +++ b/support/popt.c @@ -31,7 +31,7 @@ static char * strerror(int errno) { if ((0 <= errno) && (errno < sys_nerr)) return sys_errlist[errno]; else - return "unknown errno"; + return POPT_("unknown errno"); } #endif @@ -404,8 +404,7 @@ int poptGetNextOpt(poptContext con) { break; default: - /* XXX I18N? */ - fprintf(stdout, "option type (%d) not implemented in popt\n", + fprintf(stdout, POPT_("option type (%d) not implemented in popt\n"), opt->argInfo & POPT_ARG_MASK); exit(1); } @@ -529,21 +528,21 @@ char * poptBadOption(poptContext con, int flags) { const char * poptStrerror(const int error) { switch (error) { case POPT_ERROR_NOARG: - return "missing argument"; + return POPT_("missing argument"); case POPT_ERROR_BADOPT: - return "unknown option"; + return POPT_("unknown option"); case POPT_ERROR_OPTSTOODEEP: - return "aliases nested too deeply"; + return POPT_("aliases nested too deeply"); case POPT_ERROR_BADQUOTE: - return "error in paramter quoting"; + return POPT_("error in paramter quoting"); case POPT_ERROR_BADNUMBER: - return "invalid numeric value"; + return POPT_("invalid numeric value"); case POPT_ERROR_OVERFLOW: - return "number too large or too small"; + return POPT_("number too large or too small"); case POPT_ERROR_ERRNO: return strerror(errno); default: - return "unknown error"; + return POPT_("unknown error"); } } diff --git a/support/popthelp.c b/support/popthelp.c index df5ed26..021e044 100644 --- a/support/popthelp.c +++ b/support/popthelp.c @@ -26,23 +26,26 @@ static void displayArgs(poptContext con, enum poptCallbackReason foo, struct poptOption poptHelpOptions[] = { { NULL, '\0', POPT_ARG_CALLBACK, &displayArgs, '\0', NULL }, - { "help", '?', 0, NULL, '?', "Show this help message" }, - { "usage", '\0', 0, NULL, 'u', "Display brief usage message" }, + { "help", '?', 0, NULL, '?', N_("Show this help message") }, + { "usage", '\0', 0, NULL, 'u', N_("Display brief usage message") }, { NULL, '\0', 0, NULL, 0 } } ; static const char * getArgDescrip(const struct poptOption * opt) { if (!(opt->argInfo & POPT_ARG_MASK)) return NULL; - if (opt->argDescrip) return opt->argDescrip; - return "ARG"; + if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2)) + if (opt->argDescrip) return POPT_(opt->argDescrip); + + if (opt->argDescrip) return _(opt->argDescrip); + return POPT_("ARG"); } static void singleOptionHelp(FILE * f, int maxLeftCol, const struct poptOption * opt) { int indentLength = maxLeftCol + 5; int lineLength = 79 - indentLength; - const char * help = opt->descrip; + const char * help = _(opt->descrip); int helpLength; const char * ch; char format[10]; @@ -131,7 +134,7 @@ static void singleTableHelp(FILE * f, const struct poptOption * table, while (opt->longName || opt->shortName || opt->arg) { if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) { if (opt->descrip) - fprintf(f, "\n%s\n", opt->descrip); + fprintf(f, "\n%s\n", _(opt->descrip)); singleTableHelp(f, opt->arg, left); } opt++; @@ -142,7 +145,7 @@ static int showHelpIntro(poptContext con, FILE * f) { int len = 6; char * fn; - fprintf(f, "Usage:"); + fprintf(f, POPT_("Usage:")); if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) { fn = con->optionStack->argv[0]; if (strchr(fn, '/')) fn = strchr(fn, '/') + 1; @@ -160,7 +163,7 @@ void poptPrintHelp(poptContext con, FILE * f, int flags) { if (con->otherHelp) fprintf(f, " %s\n", con->otherHelp); else - fprintf(f, " [OPTION...]\n"); + fprintf(f, " %s\n", POPT_("[OPTION...]")); leftColWidth = maxArgWidth(con->options); singleTableHelp(f, con->options, leftColWidth); diff --git a/support/poptint.h b/support/poptint.h index 195039a..5d99be5 100644 --- a/support/poptint.h +++ b/support/poptint.h @@ -43,4 +43,22 @@ struct poptContext_s { char * otherHelp; }; +#ifdef HAVE_LIBINTL_H +#include <libintl.h> +#endif + +#ifdef HAVE_GETTEXT +#define _(foo) gettext(foo) +#else +#define _(foo) (foo) +#endif + +#ifdef HAVE_DGETTEXT +#define POPT_(foo) dgettext("popt", foo) +#else +#define POPT_(foo) (foo) +#endif + +#define N_(foo) (foo) + #endif |