diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/gpg-error.c | 50 |
3 files changed, 58 insertions, 2 deletions
@@ -1,3 +1,11 @@ +2004-04-22 Marcus Brinkmann <[email protected]> + + * 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. + 2004-04-02 Thomas Schwinge <[email protected]> * autogen.sh: Added ACLOCAL_FLAGS. diff --git a/src/Makefile.am b/src/Makefile.am index e67d49f..adcf028 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -51,8 +51,10 @@ libgpg_error_la_SOURCES = gpg-error.h gettext.h \ libgpg_error_la_LIBADD = @LTLIBINTL@ +localedir = $(datadir)/locale bin_PROGRAMS = gpg-error gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c +gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" gpg_error_LDADD = ./libgpg-error.la err-sources.h: Makefile mkstrtable.awk err-sources.h.in 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 <limits.h> #include <stdio.h> +#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 <locale.h> +# endif +# ifdef ENABLE_NLS +# include <libintl.h> +# 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 <gpg-error.h> @@ -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++; } |