aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog9
-rw-r--r--e-util/Makefile.am2
-rw-r--r--e-util/e-unicode-i18n.c59
-rw-r--r--e-util/e-unicode-i18n.h17
4 files changed, 87 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index fe054a5cde..f8c0a19dd6 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,12 @@
+2001-08-24 Zbigniew Chyla <cyba@gnome.pl>
+
+ * Makefile.am (libeutil_la_SOURCES): Added e-unicode-i18n.c and
+ e-unicode-i18n.h.
+
+ * e-unicode-i18n.[ch]: New files with two extra functions
+ (e_utf8_gettext, e_utf8_dgettext) and U_() macro.
+ Should be used instead of _() if we need UTF-8 string.
+
2001-08-23 Zbigniew Chyla <cyba@gnome.pl>
* e-request.c (e_request_string): Modified to accept and return UTF-8
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 3f82668e2e..231d04b64a 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -56,6 +56,8 @@ libeutil_la_SOURCES = \
e-sexp.h \
e-time-utils.c \
e-time-utils.h \
+ e-unicode-i18n.c \
+ e-unicode-i18n.h \
e-url.c \
e-url.h \
md5-utils.c \
diff --git a/e-util/e-unicode-i18n.c b/e-util/e-unicode-i18n.c
new file mode 100644
index 0000000000..94cf05ecd9
--- /dev/null
+++ b/e-util/e-unicode-i18n.c
@@ -0,0 +1,59 @@
+/*
+ * e-unicode-i18n.c
+ *
+ * Author: Zbigniew Chyla <cyba@gnome.pl>
+ *
+ * Copyright (C) 2001 Ximian, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <gal/widgets/e-unicode.h>
+#include "e-unicode-i18n.h"
+
+static GHashTable *locale_to_utf8_hash = NULL;
+
+static const char *
+locale_to_utf8 (const char *string)
+{
+ char *utf;
+
+ if (locale_to_utf8_hash == NULL) {
+ locale_to_utf8_hash = g_hash_table_new (&g_str_hash, &g_str_equal);
+ }
+
+ utf = g_hash_table_lookup (locale_to_utf8_hash, string);
+ if (utf == NULL) {
+ utf = e_utf8_from_locale_string (string);
+ g_hash_table_insert (locale_to_utf8_hash, g_strdup (string), utf);
+ }
+
+ return utf;
+}
+
+const char *
+e_utf8_gettext (const char *string)
+{
+ if (string == NULL) {
+ return NULL;
+ } else if (string[0] == '\0') {
+ return "";
+ } else {
+ return locale_to_utf8 (gettext (string));
+ }
+}
+
+const char *
+e_utf8_dgettext (const char *domain, const char *string)
+{
+ if (string == NULL) {
+ return NULL;
+ } else if (string[0] == '\0') {
+ return "";
+ } else {
+ return locale_to_utf8 (dgettext (domain, string));
+ }
+}
diff --git a/e-util/e-unicode-i18n.h b/e-util/e-unicode-i18n.h
new file mode 100644
index 0000000000..e8281891bc
--- /dev/null
+++ b/e-util/e-unicode-i18n.h
@@ -0,0 +1,17 @@
+#ifndef _E_UNICODE_I18N_H
+#define _E_UNICODE_I18N_H
+
+#include <libgnome/gnome-defs.h>
+#include <libgnome/gnome-i18n.h>
+
+const char *e_utf8_gettext (const char *string);
+const char *e_utf8_dgettext (const char *domain, const char *string);
+
+#undef U_
+#ifdef GNOME_EXPLICIT_TRANSLATION_DOMAIN
+# define U_(domain,string) e_utf8_dgettext (domain, string)
+#else
+# define U_(string) e_utf8_gettext (string)
+#endif
+
+#endif /* _E_UNICODE_I18N_H */