From b735fc8d178ac32a3610f1c6e45a04ad5aa2845e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 11 Oct 2010 18:36:43 -0400 Subject: Initial gettext support for C utils Add automatic creation of python an C file lists for potfiles Deletes useless copy of Makefile in install/po Remove duplicate maintainer-clean target Add debug target that prints file lists Unbreak update-po target, merges in patch from John --- ipa-client/config.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'ipa-client/config.c') diff --git a/ipa-client/config.c b/ipa-client/config.c index c32946ed6..69bd9cb33 100644 --- a/ipa-client/config.c +++ b/ipa-client/config.c @@ -37,6 +37,11 @@ #include #include +#include +#include "config.h" +#include +#define _(STRING) gettext(STRING) + char * read_config_file(const char *filename) { @@ -47,14 +52,14 @@ read_config_file(const char *filename) fd = open(filename, O_RDONLY); if (fd == -1) { - fprintf(stderr, "cannot open configuration file %s\n", filename); + fprintf(stderr, _("cannot open configuration file %s\n"), filename); return NULL; } /* stat() the file so we know the size and can pre-allocate the right * amount of memory. */ if (fstat(fd, &st) == -1) { - fprintf(stderr, "cannot stat() configuration file %s\n", filename); + fprintf(stderr, _("cannot stat() configuration file %s\n"), filename); return NULL; } left = st.st_size; @@ -67,7 +72,7 @@ read_config_file(const char *filename) if (res == 0) break; if (res < 0) { - fprintf(stderr, "read error\n"); + fprintf(stderr, _("read error\n")); close(fd); free(dest); return NULL; @@ -159,3 +164,27 @@ get_config_entry(char * in_data, const char *section, const char *key) free(data); return NULL; } + +int init_gettext(void) +{ + char *c; + + c = setlocale(LC_ALL, ""); + if (!c) { + return EIO; + } + + errno = 0; + c = bindtextdomain(PACKAGE, LOCALEDIR); + if (c == NULL) { + return errno; + } + + errno = 0; + c = textdomain(PACKAGE); + if (c == NULL) { + return errno; + } + + return 0; +} -- cgit