aboutsummaryrefslogtreecommitdiff
path: root/modules/devices.c
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-08-10 11:55:41 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2017-08-11 02:52:21 -0700
commit242cf8f80c05d655c3ae6ce22ec3751668b11895 (patch)
tree1d08179df1d07f2e7114ef0c0151d634dfd21f56 /modules/devices.c
parent05c4a4c9451b7b07577255f7927cec6d70f2cf8d (diff)
Make procs/cores/threads description string translatable with plural forms
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules/devices.c')
-rw-r--r--modules/devices.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/modules/devices.c b/modules/devices.c
index affa2a35..b524f908 100644
--- a/modules/devices.c
+++ b/modules/devices.c
@@ -133,12 +133,23 @@ static gint proc_cmp(Processor *a, Processor *b) {
gchar *processor_describe_default(GSList * processors)
{
int packs, cores, threads;
+ const gchar *packs_fmt, *cores_fmt, *threads_fmt;
+ gchar *ret, *full_fmt;
+
cpu_procs_cores_threads(&packs, &cores, &threads);
+
/* if topology info was available, else fallback to old method */
- if (cores > 0)
- return g_strdup_printf("%d physical processor(s); %d core(s); %d thread(s)", packs, cores, threads);
- else
+ if (cores > 0) {
+ packs_fmt = ngettext("%d physical processor", "%d physical processors", packs);
+ cores_fmt = ngettext("%d core", "%d cores", cores);
+ threads_fmt = ngettext("%d thread", "%d threads", threads);
+ full_fmt = g_strdup_printf(_(/*/NP procs; NC cores; NT threads*/ "%s; %s; %s"), packs_fmt, cores_fmt, threads_fmt);
+ ret = g_strdup_printf(full_fmt, packs, cores, threads);
+ g_free(full_fmt);
+ return ret;
+ } else {
return processor_describe_by_counting_names(processors);
+ }
}
gchar *processor_name_default(GSList * processors)