summaryrefslogtreecommitdiffstats
path: root/avahi-common
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-12-17 12:36:14 +0000
committerLennart Poettering <lennart@poettering.net>2007-12-17 12:36:14 +0000
commitbb8bd5490a71bc77570653cf53be88edd37679e3 (patch)
treec844fce7acfadab8489b76f9f1b510a52911fdc6 /avahi-common
parentb898298a5aacb4596646eccbcccdd8afd27e90a5 (diff)
add i18n support
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1593 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-common')
-rw-r--r--avahi-common/Makefile.am10
-rw-r--r--avahi-common/error.c133
-rw-r--r--avahi-common/i18n.c40
-rw-r--r--avahi-common/i18n.h55
4 files changed, 168 insertions, 70 deletions
diff --git a/avahi-common/Makefile.am b/avahi-common/Makefile.am
index cd21c11..e0aa56e 100644
--- a/avahi-common/Makefile.am
+++ b/avahi-common/Makefile.am
@@ -1,7 +1,7 @@
# $Id: Makefile.am 90 2005-05-23 16:15:12Z lennart $
#
# This file is part of avahi.
-#
+#
# avahi is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2 of the
@@ -53,7 +53,7 @@ noinst_PROGRAMS = \
endif
lib_LTLIBRARIES = \
- libavahi-common.la
+ libavahi-common.la
libavahi_common_la_SOURCES = \
malloc.c malloc.h \
@@ -67,9 +67,10 @@ libavahi_common_la_SOURCES = \
thread-watch.c thread-watch.h \
watch.h gccmacro.h \
rlist.h rlist.c \
- utf8.c utf8.h
+ utf8.c utf8.h \
+ i18n.c i18n.h
-libavahi_common_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)
+libavahi_common_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -DAVAHI_LOCALEDIR=\"$(avahilocaledir)\"
libavahi_common_la_LIBADD = $(AM_LDADD) $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)
libavahi_common_la_LDFLAGS = $(AM_LDFLAGS) -export-dynamic -version-info $(LIBAVAHI_COMMON_VERSION_INFO)
@@ -128,4 +129,3 @@ noinst_HEADERS = \
dbus-watch-glue.h
endif
-
diff --git a/avahi-common/error.c b/avahi-common/error.c
index 92a2234..fb9bd38 100644
--- a/avahi-common/error.c
+++ b/avahi-common/error.c
@@ -2,17 +2,17 @@
/***
This file is part of avahi.
-
+
avahi is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
-
+
avahi is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with avahi; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
@@ -24,73 +24,76 @@
#endif
#include "error.h"
+#include "i18n.h"
const char *avahi_strerror(int error) {
-
+
const char * const msg[- AVAHI_ERR_MAX] = {
- "OK",
- "Operation failed",
- "Bad state",
- "Invalid host name",
- "Invalid domain name",
- "No suitable network protocol available",
- "Invalid DNS TTL",
- "Resource record key is pattern",
- "Local name collision",
- "Invalid record",
-
- "Invalid service name",
- "Invalid service type",
- "Invalid port number",
- "Invalid record key",
- "Invalid address",
- "Timeout reached",
- "Too many clients",
- "Too many objects",
- "Too many entries",
- "OS Error",
-
- "Access denied",
- "Invalid operation",
- "An unexpected D-Bus error occured",
- "Daemon connection failed",
- "Memory exhausted",
- "The object passed in was not valid",
- "Daemon not running",
- "Invalid interface index",
- "Invalid protocol specification",
- "Invalid flags",
-
- "Not found",
- "Invalid configuration",
- "Version mismatch",
- "Invalid service subtype",
- "Invalid packet",
- "Invalid DNS return code",
- "DNS failure: FORMERR",
- "DNS failure: SERVFAIL",
- "DNS failure: NXDOMAIN",
- "DNS failure: NOTIMP",
-
- "DNS failure: REFUSED",
- "DNS failure: YXDOMAIN",
- "DNS failure: YXRRSET",
- "DNS failure: NXRRSET",
- "DNS failure: NOTAUTH",
- "DNS failure: NOTZONE",
- "Invalid RDATA",
- "Invalid DNS type",
- "Invalid DNS class",
- "Not supported",
-
- "Not permitted",
- "Invalid argument",
- "Is empty",
- "The requested operation is invalid because redundant"
+ N_("OK"),
+ N_("Operation failed"),
+ N_("Bad state"),
+ N_("Invalid host name"),
+ N_("Invalid domain name"),
+ N_("No suitable network protocol available"),
+ N_("Invalid DNS TTL"),
+ N_("Resource record key is pattern"),
+ N_("Local name collision"),
+ N_("Invalid record"),
+
+ N_("Invalid service name"),
+ N_("Invalid service type"),
+ N_("Invalid port number"),
+ N_("Invalid record key"),
+ N_("Invalid address"),
+ N_("Timeout reached"),
+ N_("Too many clients"),
+ N_("Too many objects"),
+ N_("Too many entries"),
+ N_("OS Error"),
+
+ N_("Access denied"),
+ N_("Invalid operation"),
+ N_("An unexpected D-Bus error occured"),
+ N_("Daemon connection failed"),
+ N_("Memory exhausted"),
+ N_("The object passed in was not valid"),
+ N_("Daemon not running"),
+ N_("Invalid interface index"),
+ N_("Invalid protocol specification"),
+ N_("Invalid flags"),
+
+ N_("Not found"),
+ N_("Invalid configuration"),
+ N_("Version mismatch"),
+ N_("Invalid service subtype"),
+ N_("Invalid packet"),
+ N_("Invalid DNS return code"),
+ N_("DNS failure: FORMERR"),
+ N_("DNS failure: SERVFAIL"),
+ N_("DNS failure: NXDOMAIN"),
+ N_("DNS failure: NOTIMP"),
+
+ N_("DNS failure: REFUSED"),
+ N_("DNS failure: YXDOMAIN"),
+ N_("DNS failure: YXRRSET"),
+ N_("DNS failure: NXRRSET"),
+ N_("DNS failure: NOTAUTH"),
+ N_("DNS failure: NOTZONE"),
+ N_("Invalid RDATA"),
+ N_("Invalid DNS type"),
+ N_("Invalid DNS class"),
+ N_("Not supported"),
+
+ N_("Not permitted"),
+ N_("Invalid argument"),
+ N_("Is empty"),
+ N_("The requested operation is invalid because redundant")
};
+ avahi_init_i18n();
+
if (-error < 0 || -error >= -AVAHI_ERR_MAX)
- return "Invalid Error Code";
+ return _("Invalid Error Code");
- return msg[-error];
+ return _(msg[-error]);
}
diff --git a/avahi-common/i18n.c b/avahi-common/i18n.c
new file mode 100644
index 0000000..20f3b3a
--- /dev/null
+++ b/avahi-common/i18n.c
@@ -0,0 +1,40 @@
+/* $Id$ */
+
+/***
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+ Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+ ***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "i18n.h"
+
+void avahi_init_i18n(void) {
+
+ /* Not really thread safe, but this doesn't matter much since
+ * bindtextdomain is supposed to be idempotent anyway. */
+
+ static int done = 0;
+
+ if (!done) {
+ bindtextdomain(GETTEXT_PACKAGE, AVAHI_LOCALEDIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+ done = 1;
+ }
+}
diff --git a/avahi-common/i18n.h b/avahi-common/i18n.h
new file mode 100644
index 0000000..e246736
--- /dev/null
+++ b/avahi-common/i18n.h
@@ -0,0 +1,55 @@
+#ifndef fooi18nhfoo
+#define fooi18nhfoo
+
+/* $Id$ */
+
+/***
+ This file is part of avahi.
+
+ avahi is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ avahi is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
+ Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with avahi; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#if !defined(GETTEXT_PACKAGE)
+#error "Something is very wrong here, config.h needs to be included first"
+#endif
+
+#ifdef ENABLE_NLS
+
+#include <libintl.h>
+
+#define _(String) dgettext(GETTEXT_PACKAGE, String)
+#ifdef gettext_noop
+#define N_(String) gettext_noop(String)
+#else
+#define N_(String) (String)
+#endif
+
+#else /* NLS is disabled */
+
+#define _(String) (String)
+#define N_(String) (String)
+#define textdomain(String) (String)
+#define gettext(String) (String)
+#define dgettext(Domain,String) (String)
+#define dcgettext(Domain,String,Type) (String)
+#define bindtextdomain(Domain,Directory) (Domain)
+#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
+
+#endif /* ENABLE_NLS */
+
+void avahi_init_i18n(void);
+
+#endif