[libosinfo v3 2/4] Load localized values for entity params

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>

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


[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux