summaryrefslogtreecommitdiffstats
path: root/hivex/hivexml.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-01-29 14:56:13 +0000
committerRichard Jones <rjones@redhat.com>2010-01-29 15:11:59 +0000
commita6025c11d97ed5802b3729a93d224d2baa20ff12 (patch)
tree6dd670b706070e29496a62052447b22086434c0b /hivex/hivexml.c
parent088d0c53cfe0dcb20b87707a9055175b2fd6b72f (diff)
downloadlibguestfs-a6025c11d97ed5802b3729a93d224d2baa20ff12.tar.gz
libguestfs-a6025c11d97ed5802b3729a93d224d2baa20ff12.tar.xz
libguestfs-a6025c11d97ed5802b3729a93d224d2baa20ff12.zip
Set locale in C programs so l10n works (RHBZ#559962).
This commit adds the calls to setlocale &c to all of the current C programs. It also adds l10n support to hivexget and hivexml which lacked them previously. To test this, try: LANG=pa_IN.UTF-8 guestfish --cmd-help (You can only do this test after installing the package, or at least the 'pa.mo' mo-file in the correct place).
Diffstat (limited to 'hivex/hivexml.c')
-rw-r--r--hivex/hivexml.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/hivex/hivexml.c b/hivex/hivexml.c
index 7fb419f9..90cb22bd 100644
--- a/hivex/hivexml.c
+++ b/hivex/hivexml.c
@@ -30,6 +30,15 @@
#include "hivex.h"
+#ifdef HAVE_GETTEXT
+#include "gettext.h"
+#define _(str) dgettext(PACKAGE, (str))
+//#define N_(str) dgettext(PACKAGE, (str))
+#else
+#define _(str) str
+//#define N_(str) str
+#endif
+
/* Callback functions. */
static int node_start (hive_h *, void *, hive_node_h, const char *name);
static int node_end (hive_h *, void *, hive_node_h, const char *name);
@@ -58,14 +67,18 @@ static struct hivex_visitor visitor = {
#define XML_CHECK(proc, args) \
do { \
if ((proc args) == -1) { \
- fprintf (stderr, "%s: failed to write XML document\n", #proc); \
- exit (EXIT_FAILURE); \
+ fprintf (stderr, _("%s: failed to write XML document\n"), #proc); \
+ exit (EXIT_FAILURE); \
} \
} while (0)
int
main (int argc, char *argv[])
{
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEBASEDIR);
+ textdomain (PACKAGE);
+
int c;
int open_flags = 0;
int visit_flags = 0;
@@ -85,7 +98,7 @@ main (int argc, char *argv[])
}
if (optind + 1 != argc) {
- fprintf (stderr, "hivexml: missing name of input file\n");
+ fprintf (stderr, _("hivexml: missing name of input file\n"));
exit (EXIT_FAILURE);
}
@@ -104,7 +117,7 @@ main (int argc, char *argv[])
xmlTextWriterPtr writer;
writer = xmlNewTextWriterFilename ("/dev/stdout", 0);
if (writer == NULL) {
- fprintf (stderr, "xmlNewTextWriterFilename: failed to create XML writer\n");
+ fprintf (stderr, _("xmlNewTextWriterFilename: failed to create XML writer\n"));
exit (EXIT_FAILURE);
}