[virt-tools-list] [libosinfo v3 2/4] Load localized values for entity params

Zeeshan Ali (Khattak) zeeshanak at gnome.org
Tue Oct 23 21:02:29 UTC 2012


From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>

Use the localized values of entity params if available.
---
 osinfo/osinfo_loader.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/osinfo/osinfo_loader.c b/osinfo/osinfo_loader.c
index a0034f5..d592cf6 100644
--- a/osinfo/osinfo_loader.c
+++ b/osinfo/osinfo_loader.c
@@ -228,14 +228,25 @@ static void osinfo_loader_entity(OsinfoLoader *loader,
 
     /* Standard well-known keys first, allow single value only */
     for (i = 0 ; keys[i] != NULL ; i++) {
-        gchar *xpath = g_strdup_printf("string(./%s)", keys[i]);
+        gboolean translatable;
+
+        gchar *xpath = g_strdup_printf("string(./%s[@xml:lang])", keys[i]);
         gchar *value = osinfo_loader_string(xpath, ctxt, err);
+        if (value == NULL) {
+            translatable = FALSE;
+            g_free(xpath);
+            xpath = g_strdup_printf("string(./%s)", keys[i]);
+            value = osinfo_loader_string(xpath, ctxt, err);
+        } else
+            translatable = TRUE;
         g_free(xpath);
         if (error_is_set(err))
             return;
 
         if (value) {
-            osinfo_entity_set_param(entity, keys[i], value);
+            const gchar *local_value =
+                (translatable)? g_dgettext(GETTEXT_PACKAGE, value) : value;
+            osinfo_entity_set_param(entity, keys[i], local_value);
             g_free(value);
         }
     }
-- 
1.7.12.1




More information about the virt-tools-list mailing list