summaryrefslogtreecommitdiff
path: root/modules/devices
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-07-12 00:46:38 -0500
committerLeandro Pereira <leandro@hardinfo.org>2017-07-12 19:38:41 -0700
commitfb2910e7a2931ff84c8f3f859e76623a295275f8 (patch)
tree1a408b35be2ffd1abc906c95824ab673945bc795 /modules/devices
parent3824849f670ea9249a35a72b1f8f475e5f3fdea3 (diff)
Fix Computer -> Summary -> RAM for non-English
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/devices')
-rw-r--r--modules/devices/devmemory.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/modules/devices/devmemory.c b/modules/devices/devmemory.c
index 7131536c..8fef9d6b 100644
--- a/modules/devices/devmemory.c
+++ b/modules/devices/devmemory.c
@@ -23,10 +23,10 @@ GHashTable *memlabels = NULL;
void scan_memory_do(void)
{
- gchar **keys, *tmp;
+ gchar **keys, *tmp, *tmp_label;
static gint offset = -1;
gint i;
-
+
if (offset == -1) {
/* gah. linux 2.4 adds three lines of data we don't need in
/proc/meminfo */
@@ -38,38 +38,39 @@ void scan_memory_do(void)
offset = 0;
}
}
-
+
g_file_get_contents("/proc/meminfo", &meminfo, NULL, NULL);
-
+
keys = g_strsplit(meminfo, "\n", 0);
g_free(meminfo);
g_free(lginterval);
-
+
meminfo = g_strdup("");
lginterval = g_strdup("");
-
+
for (i = offset; keys[i]; i++) {
gchar **newkeys = g_strsplit(keys[i], ":", 0);
-
+
if (!newkeys[0]) {
g_strfreev(newkeys);
break;
}
-
+
+ g_strstrip(newkeys[0]);
g_strstrip(newkeys[1]);
-
- if ((tmp = g_hash_table_lookup(memlabels, newkeys[0]))) {
- g_free(newkeys[0]);
- newkeys[0] = g_strdup(tmp);
- }
-
+
+ /* try to find a localizable label */
+ tmp_label = g_hash_table_lookup(memlabels, newkeys[0]);
+ if (tmp_label == NULL)
+ tmp_label = newkeys[0];
+
moreinfo_add_with_prefix("DEV", newkeys[0], g_strdup(newkeys[1]));
- tmp = g_strconcat(meminfo, newkeys[0], "=", newkeys[1], "\n", NULL);
+ tmp = g_strconcat(meminfo, _(tmp_label), "=", newkeys[1], "\n", NULL);
g_free(meminfo);
meminfo = tmp;
-
+
tmp = g_strconcat(lginterval,
"UpdateInterval$", newkeys[0], "=1000\n", NULL);
g_free(lginterval);
@@ -86,21 +87,21 @@ void init_memory_labels(void)
char *proc_label;
char *real_label;
} proc2real[] = {
- { "MemTotal", N_("Total Memory") },
- { "MemFree", N_("Free Memory") },
- { "SwapCached", N_("Cached Swap") },
- { "HighTotal", N_("High Memory") },
- { "HighFree", N_("Free High Memory") },
- { "LowTotal", N_("Low Memory") },
- { "LowFree", N_("Free Low Memory") },
- { "SwapTotal", N_("Virtual Memory") },
- { "SwapFree", N_("Free Virtual Memory") },
+ { "MemTotal", N_("Total Memory") },
+ { "MemFree", N_("Free Memory") },
+ { "SwapCached", N_("Cached Swap") },
+ { "HighTotal", N_("High Memory") },
+ { "HighFree", N_("Free High Memory") },
+ { "LowTotal", N_("Low Memory") },
+ { "LowFree", N_("Free Low Memory") },
+ { "SwapTotal", N_("Virtual Memory") },
+ { "SwapFree", N_("Free Virtual Memory") },
{ NULL },
};
gint i;
memlabels = g_hash_table_new(g_str_hash, g_str_equal);
-
+
for (i = 0; proc2real[i].proc_label; i++) {
g_hash_table_insert(memlabels, proc2real[i].proc_label,
_(proc2real[i].real_label));