>From 94bc7097a176c90127a9ff0106e81b4fce6e9ff2 Mon Sep 17 00:00:00 2001
From: Didier Roche <[email protected]>
Date: Thu, 29 Jan 2015 16:12:58 +0100
Subject: [PATCH 4/9] Add gettext support
---
configure.ac | 1 +
src/shared/util.c | 8 ++++++++
src/shared/util.h | 2 ++
3 files changed, 11 insertions(+)
diff --git a/configure.ac b/configure.ac
index 12e4ab2..1a2c02c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,7 @@ AS_IF([test -z "$INTLTOOL_POLICY_RULE"], [
GETTEXT_PACKAGE=systemd
AC_SUBST(GETTEXT_PACKAGE)
+AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [systemd])
AC_PROG_MKDIR_P
AC_PROG_LN_S
diff --git a/src/shared/util.c b/src/shared/util.c
index 891182a..dafec01 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -25,6 +25,8 @@
#include <errno.h>
#include <stdlib.h>
#include <signal.h>
+#include <libintl.h>
+#include <locale.h>
#include <stdio.h>
#include <syslog.h>
#include <sched.h>
@@ -70,6 +72,7 @@
#include <sys/auxv.h>
#endif
+#include "config.h"
#include "macro.h"
#include "util.h"
#include "ioprio.h"
@@ -5773,6 +5776,11 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
return NULL;
}
+void init_gettext(void) {
+ setlocale(LC_ALL, "");
+ textdomain(GETTEXT_PACKAGE);
+}
+
bool is_locale_utf8(void) {
const char *set;
static int cached_answer = -1;
diff --git a/src/shared/util.h b/src/shared/util.h
index ca0c2e5..4450ef5 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -740,6 +740,8 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
int (*compar) (const void *, const void *, void *),
void *arg);
+#define _(String) gettext (String)
+void init_gettext(void);
bool is_locale_utf8(void);
typedef enum DrawSpecialChar {
--
2.1.4
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel