Add localized strings and .pot file

This commit is contained in:
rcassani 2021-11-28 13:51:58 -05:00
parent 02e313de81
commit 0c1a4793e4
2 changed files with 276 additions and 14 deletions

View File

@ -7,25 +7,32 @@ const Cinnamon = imports.gi.Cinnamon;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const Cairo = imports.cairo; const Cairo = imports.cairo;
const St = imports.gi.St; const St = imports.gi.St;
const Util = imports.misc.util; //const Util = imports.misc.util;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gettext = imports.gettext;
const UUID = "system-monitor-graph@rcassani";
const DESKLET_PATH = imports.ui.deskletManager.deskletMeta[UUID].path;
const GIB_TO_KIB = 1048576; // 1 GiB = 1,048,576 kiB const GIB_TO_KIB = 1048576; // 1 GiB = 1,048,576 kiB
const GB_TO_B = 1000000000; // 1 GB = 1,000,000,000 B const GB_TO_B = 1000000000; // 1 GB = 1,000,000,000 B
const GIB_TO_MIB = 1024; // 1 GiB = 1,042 MiB const GIB_TO_MIB = 1024; // 1 GiB = 1,042 MiB
const UUID = "system-monitor-graph@rcassani";
const DESKLET_PATH = imports.ui.deskletManager.deskletMeta[UUID].path;
function MyDesklet(metadata, desklet_id) { Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale");
function _(str) {
return Gettext.dgettext(UUID, str);
}
function SystemMonitorGraph(metadata, desklet_id) {
this._init(metadata, desklet_id); this._init(metadata, desklet_id);
} }
function main(metadata, desklet_id) { function main(metadata, desklet_id) {
return new MyDesklet(metadata, desklet_id); return new SystemMonitorGraph(metadata, desklet_id);
} }
MyDesklet.prototype = { SystemMonitorGraph.prototype = {
__proto__: Desklet.Desklet.prototype, __proto__: Desklet.Desklet.prototype,
_init: function(metadata, desklet_id) { _init: function(metadata, desklet_id) {
@ -139,7 +146,7 @@ MyDesklet.prototype = {
case "cpu": case "cpu":
let cpu_use = this.get_cpu_use(); let cpu_use = this.get_cpu_use();
value = cpu_use / 100; value = cpu_use / 100;
text1 = "CPU"; text1 = _("CPU");
text2 = Math.round(cpu_use).toString() + "%"; text2 = Math.round(cpu_use).toString() + "%";
break; break;
@ -147,10 +154,10 @@ MyDesklet.prototype = {
let ram_values = this.get_ram_values(); let ram_values = this.get_ram_values();
let ram_use = 100 * ram_values[1] / ram_values[0]; let ram_use = 100 * ram_values[1] / ram_values[0];
value = ram_use / 100; value = ram_use / 100;
text1 = "RAM"; text1 = _("RAM");
text2 = Math.round(ram_use).toString() + "%" text2 = Math.round(ram_use).toString() + "%"
text3 = ram_values[1].toFixed(1) + " / " text3 = ram_values[1].toFixed(1) + " / "
+ ram_values[0].toFixed(1) + " GiB"; + ram_values[0].toFixed(1) + " " + _("GiB");
break; break;
case "hdd": case "hdd":
@ -162,8 +169,8 @@ MyDesklet.prototype = {
text1 = this.filesystem_label; text1 = this.filesystem_label;
if (text1 == "") text1 = hdd_values[0]; if (text1 == "") text1 = hdd_values[0];
text2 = Math.round(hdd_use).toString() + "%" text2 = Math.round(hdd_use).toString() + "%"
text3 = hdd_values[3].toFixed(0) + " GB free of " text3 = hdd_values[3].toFixed(0) + " " + _("GB free of") + " "
+ hdd_values[2].toFixed(0) + " GB"; + hdd_values[2].toFixed(0) + " " + _("GB");
break; break;
case "gpu": case "gpu":
@ -173,17 +180,17 @@ MyDesklet.prototype = {
case "usage": case "usage":
let gpu_use = this.get_nvidia_gpu_use(); let gpu_use = this.get_nvidia_gpu_use();
value = gpu_use / 100; value = gpu_use / 100;
text1 = "GPU Usage"; text1 = _("GPU Usage");
text2 = Math.round(gpu_use).toString() + "%"; text2 = Math.round(gpu_use).toString() + "%";
break; break;
case "memory": case "memory":
let gpu_mem_values = this.get_nvidia_gpu_mem(); let gpu_mem_values = this.get_nvidia_gpu_mem();
let gpu_mem_use = 100 * gpu_mem_values[1] / gpu_mem_values[0]; let gpu_mem_use = 100 * gpu_mem_values[1] / gpu_mem_values[0];
value = gpu_mem_use / 100; value = gpu_mem_use / 100;
text1 = "GPU Memory"; text1 = _("GPU Memory");
text2 = Math.round(gpu_mem_use).toString() + "%" text2 = Math.round(gpu_mem_use).toString() + "%"
text3 = gpu_mem_values[1].toFixed(1) + " / " text3 = gpu_mem_values[1].toFixed(1) + " / "
+ gpu_mem_values[0].toFixed(1) + " GiB"; + gpu_mem_values[0].toFixed(1) + " " + _("GiB");
break; break;
} }
break; break;

View File

@ -0,0 +1,255 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-11-28 13:30-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. settings-schema.json->type->options
#: desklet.js:149
msgid "CPU"
msgstr ""
#. settings-schema.json->type->options
#: desklet.js:157
msgid "RAM"
msgstr ""
#: desklet.js:160
#: desklet.js:193
msgid "GiB"
msgstr ""
#: desklet.js:172
msgid "GB free of"
msgstr ""
#: desklet.js:173
msgid "GB"
msgstr ""
#: desklet.js:183
msgid "GPU Usage"
msgstr ""
#: desklet.js:190
msgid "GPU Memory"
msgstr ""
#. metadata.json->name
msgid "System monitor graph"
msgstr ""
#. metadata.json->description
msgid "Creates graphs for system variables."
msgstr ""
#. settings-schema.json->head0->description
msgid "Settings for system-monitor-graph@rcassani"
msgstr ""
#. settings-schema.json->head1->description
msgid "General"
msgstr ""
#. settings-schema.json->type->description
msgid "System variable for graph"
msgstr ""
#. settings-schema.json->type->tooltip
msgid "Select the system variable to monitor."
msgstr ""
#. settings-schema.json->type->options
msgid "HDD"
msgstr ""
#. settings-schema.json->type->options
msgid "GPU"
msgstr ""
#. settings-schema.json->filesystem->description
msgid "Filesystem to monitor"
msgstr ""
#. settings-schema.json->filesystem->tooltip
msgid "Select a directory in the filesystem to monitor."
msgstr ""
#. settings-schema.json->filesystem-label->description
msgid "Filesystem label"
msgstr ""
#. settings-schema.json->filesystem-label->tooltip
msgid "Empty uses the filesystem name from df."
msgstr ""
#. settings-schema.json->gpu-manufacturer->description
msgid "GPU manufacturer"
msgstr ""
#. settings-schema.json->gpu-manufacturer->tooltip
msgid "Select the GPU manufacturer."
msgstr ""
#. settings-schema.json->gpu-manufacturer->options
msgid "NVIDIA"
msgstr ""
#. settings-schema.json->gpu-id->description
msgid "Id of GPU to monitor"
msgstr ""
#. settings-schema.json->gpu-id->tooltip
msgid "Check GPU id with nvidia-smi -L"
msgstr ""
#. settings-schema.json->gpu-variable->description
msgid "GPU variable to monitor"
msgstr ""
#. settings-schema.json->gpu-variable->tooltip
msgid "Select the GPU variable to monitor."
msgstr ""
#. settings-schema.json->gpu-variable->options
msgid "Usage"
msgstr ""
#. settings-schema.json->gpu-variable->options
msgid "Memory"
msgstr ""
#. settings-schema.json->duration->description
msgid "Duration of the graph"
msgstr ""
#. settings-schema.json->duration->tooltip
msgid "Maximum among of time to show in the graph."
msgstr ""
#. settings-schema.json->duration->options
#. settings-schema.json->refresh-interval->options
msgid "30 s"
msgstr ""
#. settings-schema.json->duration->options
msgid " 1 min"
msgstr ""
#. settings-schema.json->duration->options
msgid " 2 min"
msgstr ""
#. settings-schema.json->duration->options
msgid " 5 min"
msgstr ""
#. settings-schema.json->duration->options
msgid "10 min"
msgstr ""
#. settings-schema.json->duration->options
msgid "30 min"
msgstr ""
#. settings-schema.json->duration->options
msgid "60 min"
msgstr ""
#. settings-schema.json->refresh-interval->description
msgid "Refresh interval"
msgstr ""
#. settings-schema.json->refresh-interval->tooltip
msgid "How often a new value of the variable will be calculated."
msgstr ""
#. settings-schema.json->refresh-interval->options
msgid " 1 s"
msgstr ""
#. settings-schema.json->refresh-interval->options
msgid " 2 s"
msgstr ""
#. settings-schema.json->refresh-interval->options
msgid " 5 s"
msgstr ""
#. settings-schema.json->refresh-interval->options
msgid "10 s"
msgstr ""
#. settings-schema.json->refresh-interval->options
msgid "60 s"
msgstr ""
#. settings-schema.json->head2->description
msgid "Visual"
msgstr ""
#. settings-schema.json->background-color->description
msgid "Background color"
msgstr ""
#. settings-schema.json->background-color->tooltip
#. settings-schema.json->text-color->tooltip
#. settings-schema.json->midline-color->tooltip
msgid "RGB or RGBA."
msgstr ""
#. settings-schema.json->text-color->description
msgid "Text color"
msgstr ""
#. settings-schema.json->line-color-cpu->description
msgid "Line color CPU"
msgstr ""
#. settings-schema.json->line-color-cpu->tooltip
#. settings-schema.json->line-color-ram->tooltip
#. settings-schema.json->line-color-hdd->tooltip
#. settings-schema.json->line-color-gpu->tooltip
msgid "RGB or RGBA. Alpha is ignored"
msgstr ""
#. settings-schema.json->line-color-ram->description
msgid "Line color RAM"
msgstr ""
#. settings-schema.json->line-color-hdd->description
msgid "Line color HDD"
msgstr ""
#. settings-schema.json->line-color-gpu->description
msgid "Line color GPU"
msgstr ""
#. settings-schema.json->midline-color->description
msgid "Grid color"
msgstr ""
#. settings-schema.json->h-midlines->description
msgid "Number of horizontal lines in the grid"
msgstr ""
#. settings-schema.json->v-midlines->description
msgid "Number of vertical lines in the grid"
msgstr ""
#. settings-schema.json->scale-size->description
msgid "Scale factor for desklet size (scale factor of 1 = 330 x 120 px)"
msgstr ""