From 8350463f8446783935dee97d9dc54e7d17c277aa Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Tue, 10 Apr 2001 23:33:25 +0000 Subject: New function to translate a string and then convert it to utf8. Acts just 2001-04-10 Christopher James Lahey * gal/widgets/e-unicode.c, gal/widgets/e-unicode.h (e_xml_get_translated_utf8_string_prop_by_name): New function to translate a string and then convert it to utf8. Acts just like e_xml_get_translated_string and then calls e_utf_from_locale_string on it. * gal/util/e-xml-utils.c: Changed e_xml_get_translated_string to take a string with no underscore at the beginning and search for both that prop and the same prop with the underscore prepended. If it finds it without the underscore, it returns it. If it finds it with the underscore, it translates. * gal/util/e-xml-utils.c, gal/util/e-xml-utils.h: Reformatted these a bit. svn path=/trunk/; revision=9216 --- widgets/misc/e-unicode.c | 34 +++++++++++++++++++++++++++++++++- widgets/misc/e-unicode.h | 4 ++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'widgets') diff --git a/widgets/misc/e-unicode.c b/widgets/misc/e-unicode.c index fe16cb2102..04b5c8f802 100644 --- a/widgets/misc/e-unicode.c +++ b/widgets/misc/e-unicode.c @@ -9,6 +9,10 @@ */ #include + +#include "e-unicode.h" + +#include "gal/util/e-i18n.h" #include #include #include @@ -18,8 +22,8 @@ #include #include #include -#include "e-unicode.h" #include "e-font.h" +#include #define FONT_TESTING #define MAX_DECOMP 8 @@ -2960,3 +2964,31 @@ e_stripped_char (unicode_char_t ch) return 0; } + +gchar * +e_xml_get_translated_utf8_string_prop_by_name (const xmlNode *parent, const xmlChar *prop_name) +{ + xmlChar *prop; + gchar *ret_val = NULL; + gchar *combined_name; + + g_return_val_if_fail (parent != NULL, 0); + g_return_val_if_fail (prop_name != NULL, 0); + + prop = xmlGetProp ((xmlNode *) parent, prop_name); + if (prop != NULL) { + ret_val = e_utf8_from_locale_string (prop); + xmlFree (prop); + return ret_val; + } + + combined_name = g_strdup_printf("_%s", prop_name); + prop = xmlGetProp ((xmlNode *) parent, combined_name); + if (prop != NULL) { + ret_val = e_utf8_from_locale_string (gettext (prop)); + xmlFree (prop); + } + g_free(combined_name); + + return ret_val; +} diff --git a/widgets/misc/e-unicode.h b/widgets/misc/e-unicode.h index db12ef72ec..f9eb0a9ae6 100644 --- a/widgets/misc/e-unicode.h +++ b/widgets/misc/e-unicode.h @@ -18,6 +18,7 @@ #include #include #include +#include BEGIN_GNOME_DECLS @@ -81,6 +82,9 @@ gchar * e_utf8_xml1_encode (const gchar *text); gint e_unichar_to_utf8 (gint c, gchar *outbuf); guint32 gdk_keyval_to_unicode (guint keysym); +gchar *e_xml_get_translated_utf8_string_prop_by_name (const xmlNode *parent, + const xmlChar *prop_name); + END_GNOME_DECLS #endif -- cgit