diff options
| author | Burt P <pburt0@gmail.com> | 2017-08-08 20:32:19 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-08-14 01:56:47 -0700 | 
| commit | b7086345dc5402ceda5e079fdb9f848f00216e40 (patch) | |
| tree | 4857f2812f56d2129db47dbf34088e65f77b6431 /modules | |
| parent | 3a9d23bce93f42fee5460d55c677ff5061da8f12 (diff) | |
More "Making module information translatable"
Continuation of TotalCaesar659's work, but with the labels
broken out of the c-format string, and the Dependencies header
translatable as well.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/computer/modules.c | 80 | 
1 files changed, 44 insertions, 36 deletions
| diff --git a/modules/computer/modules.c b/modules/computer/modules.c index 1f57d338..df876e3a 100644 --- a/modules/computer/modules.c +++ b/modules/computer/modules.c @@ -20,6 +20,7 @@  #include "hardinfo.h"  #include "computer.h" +#include "cpu_util.h" /* for STRIFNULL() */  #define GET_STR(field_name,ptr)      					\    if (!ptr && strstr(tmp[0], field_name)) {				\ @@ -42,7 +43,7 @@ scan_modules_do(void)      }      g_free(module_list); -     +      module_list = NULL;      moreinfo_del_with_prefix("COMP:MOD"); @@ -51,7 +52,7 @@ scan_modules_do(void)          return;      lsmod = popen(lsmod_path, "r");      if (!lsmod) { -        g_free(lsmod_path);  +        g_free(lsmod_path);  	return;      } @@ -99,7 +100,7 @@ scan_modules_do(void)  	   remove_quotes(license); */  	/* old modutils displays <none> when there's no value for a -	   given field; this is not desirable in the module name  +	   given field; this is not desirable in the module name  	   display, so change it to an empty string */  	if (description && g_str_equal(description, "<none>")) {  	    g_free(description); @@ -121,38 +122,45 @@ scan_modules_do(void)  				      modname,  				      description ? description : ""); -#define NONE_IF_NULL(var) (var) ? (var) : "N/A" - -	/* create the module information string */ -	strmodule = g_strdup_printf(_("[Module Information]\n" -				    "Path=%s\n" -				    "Used Memory=%.2fKiB\n" -				    "[Description]\n" -				    "Name=%s\n" -				    "Description=%s\n" -				    "Version Magic=%s\n" -				    "[Copyright]\n" -				    "Author=%s\n" -				    "License=%s\n"), -				    NONE_IF_NULL(filename), -				    memory / 1024.0, -				    modname, -				    NONE_IF_NULL(description), -				    NONE_IF_NULL(vermagic), -				    NONE_IF_NULL(author), -				    NONE_IF_NULL(license)); - -	/* if there are dependencies, append them to that string */ -	if (deps && strlen(deps)) { -	    gchar **tmp = g_strsplit(deps, ",", 0); - -	    strmodule = h_strconcat(strmodule, -                                    "\n[Dependencies]\n", -                                    g_strjoinv("=\n", tmp), -                                    "=\n", NULL); -	    g_strfreev(tmp); -	    g_free(deps); -	} +    STRIFNULL(filename, _("(Not available)") ); +    STRIFNULL(description, _("(Not available)") ); +    STRIFNULL(vermagic, _("(Not available)") ); +    STRIFNULL(author, _("(Not available)") ); +    STRIFNULL(license, _("(Not available)") ); + +    /* create the module information string */ +    strmodule = g_strdup_printf("[%s]\n" +                        "%s=%s\n" +                        "%s=%.2f %s\n" +                        "[%s]\n" +                        "%s=%s\n" +                        "%s=%s\n" +                        "%s=%s\n" +                        "[%s]\n" +                        "%s=%s\n" +                        "%s=%s\n", +                        _("Module Information"), +                        _("Path"), filename, +                        _("Used Memory"), memory / 1024.0, _("KiB"), +                        _("Description"), +                        _("Name"), modname, +                        _("Description"), description, +                        _("Version Magic"), vermagic, +                        _("Copyright"), +                        _("Author"), author, +                        _("License"), license ); + +    /* if there are dependencies, append them to that string */ +    if (deps && strlen(deps)) { +        gchar **tmp = g_strsplit(deps, ",", 0); + +        strmodule = h_strconcat(strmodule, +                                "\n[", _("Dependencies"), "]\n", +                                g_strjoinv("=\n", tmp), +                                "=\n", NULL); +        g_strfreev(tmp); +        g_free(deps); +    }  	moreinfo_add_with_prefix("COMP", hashkey, strmodule);  	g_free(hashkey); @@ -164,6 +172,6 @@ scan_modules_do(void)  	g_free(filename);      }      pclose(lsmod); -     +      g_free(lsmod_path);  } | 
