aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-04-11 07:33:25 +0800
committerChris Lahey <clahey@src.gnome.org>2001-04-11 07:33:25 +0800
commit8350463f8446783935dee97d9dc54e7d17c277aa (patch)
tree4ba270eac3a19e63c7dab7556e814a64e02d2de7
parent1991d205daa7f5b5754ba67328996c904dc26ecd (diff)
downloadgsoc2013-evolution-8350463f8446783935dee97d9dc54e7d17c277aa.tar.gz
gsoc2013-evolution-8350463f8446783935dee97d9dc54e7d17c277aa.tar.zst
gsoc2013-evolution-8350463f8446783935dee97d9dc54e7d17c277aa.zip
New function to translate a string and then convert it to utf8. Acts just
2001-04-10 Christopher James Lahey <clahey@ximian.com> * 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
-rw-r--r--e-util/e-xml-utils.c62
-rw-r--r--e-util/e-xml-utils.h4
-rw-r--r--widgets/misc/e-unicode.c34
-rw-r--r--widgets/misc/e-unicode.h4
4 files changed, 90 insertions, 14 deletions
diff --git a/e-util/e-xml-utils.c b/e-util/e-xml-utils.c
index e25f159f4b..3754d42ba2 100644
--- a/e-util/e-xml-utils.c
+++ b/e-util/e-xml-utils.c
@@ -52,7 +52,9 @@ e_xml_get_child_by_name (const xmlNode *parent, const xmlChar *child_name)
* child with the name child_name and no "lang" attribute.
*/
xmlNode *
-e_xml_get_child_by_name_by_lang (const xmlNode *parent, const xmlChar *child_name, const gchar *lang)
+e_xml_get_child_by_name_by_lang (const xmlNode *parent,
+ const xmlChar *child_name,
+ const gchar *lang)
{
xmlNode *child;
/* This is the default version of the string. */
@@ -82,7 +84,10 @@ e_xml_get_child_by_name_by_lang (const xmlNode *parent, const xmlChar *child_nam
}
static xmlNode *
-e_xml_get_child_by_name_by_lang_list_with_score (const xmlNode *parent, const gchar *name, GList *lang_list, gint *best_lang_score)
+e_xml_get_child_by_name_by_lang_list_with_score (const xmlNode *parent,
+ const gchar *name,
+ GList *lang_list,
+ gint *best_lang_score)
{
xmlNodePtr best_node = NULL, node;
@@ -97,7 +102,9 @@ e_xml_get_child_by_name_by_lang_list_with_score (const xmlNode *parent, const gc
GList *l;
gint i;
- for (l = lang_list, i = 0; l != NULL && i < *best_lang_score; l = l->next, i++) {
+ for (l = lang_list, i = 0;
+ l != NULL && i < *best_lang_score;
+ l = l->next, i++) {
if (strcmp ((gchar *) l->data, lang) == 0) {
best_node = node;
*best_lang_score = i;
@@ -122,7 +129,9 @@ e_xml_get_child_by_name_by_lang_list_with_score (const xmlNode *parent, const gc
*
*/
xmlNode *
-e_xml_get_child_by_name_by_lang_list (const xmlNode *parent, const gchar *name, GList *lang_list)
+e_xml_get_child_by_name_by_lang_list (const xmlNode *parent,
+ const gchar *name,
+ GList *lang_list)
{
gint best_lang_score = INT_MAX;
@@ -132,7 +141,10 @@ e_xml_get_child_by_name_by_lang_list (const xmlNode *parent, const gchar *name,
if (lang_list == NULL) {
lang_list = gnome_i18n_get_language_list ("LC_MESSAGES");
}
- return e_xml_get_child_by_name_by_lang_list_with_score (parent, name, lang_list, &best_lang_score);
+ return e_xml_get_child_by_name_by_lang_list_with_score
+ (parent,name,
+ lang_list,
+ &best_lang_score);
}
/*
@@ -173,7 +185,9 @@ e_xml_get_integer_prop_by_name (const xmlNode *parent, const xmlChar *prop_name)
}
gint
-e_xml_get_integer_prop_by_name_with_default (const xmlNode *parent, const xmlChar *prop_name, gint def)
+e_xml_get_integer_prop_by_name_with_default (const xmlNode *parent,
+ const xmlChar *prop_name,
+ gint def)
{
xmlChar *prop;
gint ret_val = def;
@@ -190,7 +204,9 @@ e_xml_get_integer_prop_by_name_with_default (const xmlNode *parent, const xmlCha
}
void
-e_xml_set_integer_prop_by_name (xmlNode *parent, const xmlChar *prop_name, gint value)
+e_xml_set_integer_prop_by_name (xmlNode *parent,
+ const xmlChar *prop_name,
+ gint value)
{
gchar *valuestr;
@@ -212,7 +228,9 @@ e_xml_get_uint_prop_by_name (const xmlNode *parent, const xmlChar *prop_name)
}
guint
-e_xml_get_uint_prop_by_name_with_default (const xmlNode *parent, const xmlChar *prop_name, guint def)
+e_xml_get_uint_prop_by_name_with_default (const xmlNode *parent,
+ const xmlChar *prop_name,
+ guint def)
{
xmlChar *prop;
guint ret_val = def;
@@ -229,7 +247,9 @@ e_xml_get_uint_prop_by_name_with_default (const xmlNode *parent, const xmlChar *
}
void
-e_xml_set_uint_prop_by_name (xmlNode *parent, const xmlChar *prop_name, guint value)
+e_xml_set_uint_prop_by_name (xmlNode *parent,
+ const xmlChar *prop_name,
+ guint value)
{
gchar *valuestr;
@@ -242,16 +262,21 @@ e_xml_set_uint_prop_by_name (xmlNode *parent, const xmlChar *prop_name, guint va
}
gboolean
-e_xml_get_bool_prop_by_name (const xmlNode *parent, const xmlChar *prop_name)
+e_xml_get_bool_prop_by_name (const xmlNode *parent,
+ const xmlChar *prop_name)
{
g_return_val_if_fail (parent != NULL, 0);
g_return_val_if_fail (prop_name != NULL, 0);
- return e_xml_get_bool_prop_by_name_with_default (parent, prop_name, FALSE);
+ return e_xml_get_bool_prop_by_name_with_default (parent,
+ prop_name,
+ FALSE);
}
gboolean
-e_xml_get_bool_prop_by_name_with_default(const xmlNode *parent, const xmlChar *prop_name, gboolean def)
+e_xml_get_bool_prop_by_name_with_default(const xmlNode *parent,
+ const xmlChar *prop_name,
+ gboolean def)
{
xmlChar *prop;
gboolean ret_val = def;
@@ -371,14 +396,25 @@ e_xml_get_translated_string_prop_by_name (const xmlNode *parent, const xmlChar *
{
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 = g_strdup (_(prop));
+ ret_val = g_strdup (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 = g_strdup (gettext(prop));
xmlFree (prop);
}
+ g_free(combined_name);
+
return ret_val;
}
diff --git a/e-util/e-xml-utils.h b/e-util/e-xml-utils.h
index 3a4649411c..ba102c1c3d 100644
--- a/e-util/e-xml-utils.h
+++ b/e-util/e-xml-utils.h
@@ -42,6 +42,7 @@ xmlNode *e_xml_get_child_by_name_by_lang_list (const xmlNode *parent,
xmlNode *e_xml_get_child_by_name_no_lang (const xmlNode *parent,
const gchar *name);
+
gint e_xml_get_integer_prop_by_name (const xmlNode *parent,
const xmlChar *prop_name);
gint e_xml_get_integer_prop_by_name_with_default (const xmlNode *parent,
@@ -51,6 +52,7 @@ void e_xml_set_integer_prop_by_name (xmlNode *parent,
const xmlChar *prop_name,
gint value);
+
guint e_xml_get_uint_prop_by_name (const xmlNode *parent,
const xmlChar *prop_name);
guint e_xml_get_uint_prop_by_name_with_default (const xmlNode *parent,
@@ -60,6 +62,7 @@ void e_xml_set_uint_prop_by_name (xmlNode *parent,
const xmlChar *prop_name,
guint value);
+
gboolean e_xml_get_bool_prop_by_name (const xmlNode *parent,
const xmlChar *prop_name);
gboolean e_xml_get_bool_prop_by_name_with_default (const xmlNode *parent,
@@ -78,6 +81,7 @@ void e_xml_set_double_prop_by_name ( xmlNode *parent,
const xmlChar *prop_name,
gdouble value);
+
gchar *e_xml_get_string_prop_by_name (const xmlNode *parent,
const xmlChar *prop_name);
gchar *e_xml_get_string_prop_by_name_with_default (const xmlNode *parent,
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 <config.h>
+
+#include "e-unicode.h"
+
+#include "gal/util/e-i18n.h"
#include <ctype.h>
#include <string.h>
#include <stdio.h>
@@ -18,8 +22,8 @@
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkmenuitem.h>
-#include "e-unicode.h"
#include "e-font.h"
+#include <gnome-xml/xmlmemory.h>
#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 <gtk/gtkmenu.h>
#include <gtk/gtkwidget.h>
#include <libgnome/gnome-defs.h>
+#include <gnome-xml/tree.h>
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