From 0110db73b23f8add4aa41f7bdc7cc2458152de6f Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Thu, 22 Apr 2004 18:21:32 +0000 Subject: 2004-04-22 Marcus Brinkmann * src/Makefile.am (gpg_error_CPPFLAGS): New variable. (localedir): Likewise. * gpg-error.c: Include the gettext headers. (init_i18n): New function. (main): Call init_i18n, gettextize messages. --- src/gpg-error.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'src/gpg-error.c') diff --git a/src/gpg-error.c b/src/gpg-error.c index fbb596e..566d66e 100644 --- a/src/gpg-error.c +++ b/src/gpg-error.c @@ -29,6 +29,29 @@ #include #include +#ifdef USE_SIMPLE_GETTEXT + int set_gettext_file( const char *filename ); + const char *gettext( const char *msgid ); +# define _(a) gettext (a) +# define N_(a) (a) +#else +# ifdef HAVE_LOCALE_H +# include +# endif +# ifdef ENABLE_NLS +# include +# define _(a) gettext (a) +# ifdef gettext_noop +# define N_(a) gettext_noop (a) +# else +# define N_(a) (a) +# endif +# else +# define _(a) (a) +# define N_(a) (a) +# endif +#endif /*!USE_SIMPLE_GETTEXT*/ + #include @@ -225,14 +248,37 @@ get_err_from_str (char *str, gpg_error_t *err) +static void +i18n_init(void) +{ +#ifdef USE_SIMPLE_GETTEXT + set_gettext_file (PACKAGE); +#else +# ifdef ENABLE_NLS +# ifdef HAVE_LC_MESSAGES + setlocale (LC_TIME, ""); + setlocale (LC_MESSAGES, ""); +# else + setlocale (LC_ALL, "" ); +# endif + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); +# endif +#endif +} + + int main (int argc, char *argv[]) { int i = 1; + /* Setup I18N. */ + i18n_init(); + if (argc == 1) { - fprintf (stderr, "Usage: %s GPG-ERROR [...]\n", argv[0]); + fprintf (stderr, _("Usage: %s GPG-ERROR [...]\n"), argv[0]); exit (1); } @@ -253,7 +299,7 @@ main (int argc, char *argv[]) gpg_strsource (err), gpg_strerror (err)); } else - fprintf (stderr, "%s: warning: could not recognize %s\n", + fprintf (stderr, _("%s: warning: could not recognize %s\n"), argv[0], argv[i]); i++; } -- cgit v1.2.3