aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-07-18 04:02:04 -0500
committerLeandro Pereira <leandro@hardinfo.org>2017-07-19 07:20:06 -0700
commita0902475b6541553b365308241bebb93d2ee48f4 (patch)
treed02c7328e9ee7280341c9a32bf6961acb7cc9256
parentb3defed8d71d40a2727cb178ed730d26a087b3d3 (diff)
net.c: Make all string translatable
Depends on working pgettext(). Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r--modules/network/net.c165
1 files changed, 90 insertions, 75 deletions
diff --git a/modules/network/net.c b/modules/network/net.c
index beb644d5..99a5e616 100644
--- a/modules/network/net.c
+++ b/modules/network/net.c
@@ -68,7 +68,15 @@ struct _NetInfo {
};
#ifdef HAS_LINUX_WE
-const gchar *wi_operation_modes[] = { "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Unknown" };
+const gchar *wi_operation_modes[] = {
+ NC_("wi-op-mode", "Auto"),
+ NC_("wi-op-mode", "Ad-Hoc"),
+ NC_("wi-op-mode", "Managed"),
+ NC_("wi-op-mode", "Master"),
+ NC_("wi-op-mode", "Repeater"),
+ NC_("wi-op-mode", "Secondary"),
+ NC_("wi-op-mode", "(Unknown)")
+};
void get_wireless_info(int fd, NetInfo *netinfo)
{
@@ -231,40 +239,40 @@ static struct {
char *icon;
} netdev2type[] = {
/* Classic */
- { "eth", "Ethernet", "network-interface" },
- { "lo", "Loopback", "network" },
- { "ppp", "Point-to-Point", "modem" },
- { "ath", "Wireless", "wireless" },
- { "wlan", "Wireless", "wireless" },
- { "ra", "Wireless", "wireless" },
- { "wmaster", "Wireless", "wireless" },
- { "tun", "Virtual Point-to-Point (TUN)", "network" },
- { "tap", "Ethernet (TAP)", "network" },
- { "plip", "Parallel Line Internet Protocol", "network" },
- { "irlan", "Infrared", "network" },
- { "slip", "Serial Line Internet Protocol", "network" },
- { "isdn", "Integrated Services Digital Network", "modem" },
- { "sit", "IPv6-over-IPv4 Tunnel", "network" },
- { "vmnet8", "VMWare Virtual Network Interface (NAT)", "computer" },
- { "vmnet", "VMWare Virtual Network Interface", "computer" },
- { "pan", "Personal Area Network (PAN)", "bluetooth" },
- { "bnep", "Bluetooth", "bluetooth" },
- { "br", "Bridge Interface", "network" },
- { "ham", "Hamachi Virtual Personal Network", "network"},
- { "net", "Ethernet", "network-interface" },
- { "ifb", "Intermediate Functional Block", "network" },
- { "gre", "GRE Network Tunnel", "network" },
- { "msh", "Mesh Network", "wireless" },
- { "wmaster", "Wireless Master Interface", "wireless" },
- { "vboxnet", "VirtualBox Virtual Network Interface", "network" },
+ { "eth", NC_("net-if-type", "Ethernet"), "network-interface" },
+ { "lo", NC_("net-if-type", "Loopback"), "network" },
+ { "ppp", NC_("net-if-type", "Point-to-Point"), "modem" },
+ { "ath", NC_("net-if-type", "Wireless"), "wireless" },
+ { "wlan", NC_("net-if-type", "Wireless"), "wireless" },
+ { "ra", NC_("net-if-type", "Wireless"), "wireless" },
+ { "wmaster", NC_("net-if-type", "Wireless"), "wireless" },
+ { "tun", NC_("net-if-type", "Virtual Point-to-Point (TUN)"), "network" },
+ { "tap", NC_("net-if-type", "Ethernet (TAP)"), "network" },
+ { "plip", NC_("net-if-type", "Parallel Line Internet Protocol"), "network" },
+ { "irlan", NC_("net-if-type", "Infrared"), "network" },
+ { "slip", NC_("net-if-type", "Serial Line Internet Protocol"), "network" },
+ { "isdn", NC_("net-if-type", "Integrated Services Digital Network"), "modem" },
+ { "sit", NC_("net-if-type", "IPv6-over-IPv4 Tunnel"), "network" },
+ { "vmnet8", NC_("net-if-type", "VMWare Virtual Network Interface (NAT)"), "computer" },
+ { "vmnet", NC_("net-if-type", "VMWare Virtual Network Interface"), "computer" },
+ { "pan", NC_("net-if-type", "Personal Area Network (PAN)"), "bluetooth" },
+ { "bnep", NC_("net-if-type", "Bluetooth"), "bluetooth" },
+ { "br", NC_("net-if-type", "Bridge Interface"), "network" },
+ { "ham", NC_("net-if-type", "Hamachi Virtual Personal Network"), "network"},
+ { "net", NC_("net-if-type", "Ethernet"), "network-interface" },
+ { "ifb", NC_("net-if-type", "Intermediate Functional Block"), "network" },
+ { "gre", NC_("net-if-type", "GRE Network Tunnel"), "network" },
+ { "msh", NC_("net-if-type", "Mesh Network"), "wireless" },
+ { "wmaster", NC_("net-if-type", "Wireless Master Interface"), "wireless" },
+ { "vboxnet", NC_("net-if-type", "VirtualBox Virtual Network Interface"), "network" },
/* Predictable network interface device names (systemd) */
- { "en", "Ethernet", "network-interface" },
- { "sl", "Serial Line Internet Protocol", "network" },
- { "wl", "Wireless", "wireless" },
- { "ww", "Wireless (WAN)", "wireless" },
+ { "en", NC_("net-if-type", "Ethernet"), "network-interface" },
+ { "sl", NC_("net-if-type", "Serial Line Internet Protocol"), "network" },
+ { "wl", NC_("net-if-type", "Wireless"), "wireless" },
+ { "ww", NC_("net-if-type", "Wireless (WAN)"), "wireless" },
- { NULL, "Unknown", "network" },
+ { NULL, NC_("net-if-type", "(Unknown)"), "network" },
};
static void net_get_iface_type(gchar * name, gchar ** type, gchar ** icon, NetInfo *ni)
@@ -273,7 +281,7 @@ static void net_get_iface_type(gchar * name, gchar ** type, gchar ** icon, NetIn
#ifdef HAS_LINUX_WE
if (ni->is_wireless) {
- *type = "Wireless";
+ *type = "Wireless"; /* translated when used */
*icon = "wireless";
return;
@@ -285,7 +293,7 @@ static void net_get_iface_type(gchar * name, gchar ** type, gchar ** icon, NetIn
break;
}
- *type = netdev2type[i].label;
+ *type = netdev2type[i].label; /* translated when used */
*icon = netdev2type[i].icon;
}
@@ -336,8 +344,8 @@ static void scan_net_interfaces_24(void)
if (!g_file_test("/proc/net/dev", G_FILE_TEST_EXISTS)) {
if (network_interfaces) {
g_free(network_interfaces);
- network_interfaces = g_strdup("[Network Interfaces]\n"
- "None found=\n");
+ network_interfaces = g_strdup_printf("[%s]]\n%s=\n",
+ _("Network Interfaces"), _("None Found") );
}
return;
@@ -347,7 +355,7 @@ static void scan_net_interfaces_24(void)
g_free(network_icons);
- network_interfaces = g_strdup("[Network Interfaces]\n");
+ network_interfaces = g_strdup_printf("[%s]\n", _("Network Interfaces"));
network_icons = g_strdup("");
proc_net = fopen("/proc/net/dev", "r");
@@ -387,29 +395,32 @@ static void scan_net_interfaces_24(void)
network_interfaces =
h_strdup_cprintf
- ("$%s$%s=%s|%.2lfMiB|%.2lfMiB\n",
+ ("$%s$%s=%s|%.2lf%s|%.2lf%s\n",
network_interfaces, devid, ifacename, ni.ip[0] ? ni.ip : "",
- trans_mb, recv_mb);
+ trans_mb, _("MiB"), recv_mb, _("MiB"));
net_get_iface_type(ifacename, &iface_type, &iface_icon, &ni);
network_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n",
network_icons, devid,
ifacename, iface_icon);
- detailed = g_strdup_printf("[Network Adapter Properties]\n"
- "Interface Type=%s\n"
- "Hardware Address (MAC)=%02x:%02x:%02x:%02x:%02x:%02x\n"
- "MTU=%d\n"
- "[Transfer Details]\n"
- "Bytes Received=%.0lf (%.2fMiB)\n"
- "Bytes Sent=%.0lf (%.2fMiB)\n",
- iface_type,
+ detailed = g_strdup_printf("[%s]\n"
+ "%s=%s\n" /* Interface Type */
+ "%s=%02x:%02x:%02x:%02x:%02x:%02x\n" /* MAC */
+ "%s=%d\n" /* MTU */
+ "[%s]\n" /*Transfer Details*/
+ "%s=%.0lf (%.2f%s)\n" /* Bytes Received */
+ "%s=%.0lf (%.2f%s)\n" /* Bytes Sent */,
+ _("Network Adapter Properties"),
+ _("Interface Type"), C_("net-if-type", iface_type),
+ _("Hardware Address (MAC)"),
ni.mac[0], ni.mac[1],
ni.mac[2], ni.mac[3],
ni.mac[4], ni.mac[5],
- ni.mtu,
- recv_bytes, recv_mb,
- trans_bytes, trans_mb);
+ _("MTU"), ni.mtu,
+ _("Transfer Details"),
+ _("Bytes Received"), recv_bytes, recv_mb, _("MiB"),
+ _("Bytes Sent"), trans_bytes, trans_mb, _("MiB"));
#ifdef HAS_LINUX_WE
if (ni.is_wireless) {
@@ -426,28 +437,30 @@ static void scan_net_interfaces_24(void)
mw = (int) floor(pow(10.0, ((double) dbm / 10.0)));
}
- txpower = g_strdup_printf("%ddBm (%dmW)", dbm, mw);
+ txpower = g_strdup_printf("%d%s (%d%s)", dbm, _("dBm"), mw, _("mW"));
} else {
- txpower = g_strdup("Unknown");
+ txpower = g_strdup(_("(Unknown)"));
}
- detailed = h_strdup_cprintf("\n[Wireless Properties]\n"
- "Network Name (SSID)=%s\n"
- "Bit Rate=%dMb/s\n"
- "Transmission Power=%s\n"
- "Mode=%s\n"
- "Status=%d\n"
- "Link Quality=%d\n"
- "Signal / Noise=%d dBm / %d dBm (%s)\n",
+ detailed = h_strdup_cprintf("\n[%s]\n"
+ "%s=%s\n" /* Network Name (SSID) */
+ "%s=%d%s\n" /* Bit Rate */
+ "%s=%s\n" /* Transmission Power */
+ "%s=%s\n" /* Mode */
+ "%s=%d\n" /* Status */
+ "%s=%d\n" /* Link Quality */
+ "%s=%d %s / %d %s (%s)\n",
detailed,
- ni.wi_essid,
- ni.wi_rate / 1000000,
- txpower,
- wi_operation_modes[ni.wi_mode],
- ni.wi_status,
- ni.wi_quality_level,
- ni.wi_signal_level,
- ni.wi_noise_level,
+ _("Wireless Properties"),
+ _("Network Name (SSID)"), ni.wi_essid,
+ _("Bit Rate"), ni.wi_rate / 1000000, _("Mb/s"),
+ _("Transmission Power"), txpower,
+ _("Mode"), C_("wi-op-mode", wi_operation_modes[ni.wi_mode]),
+ _("Status"), ni.wi_status,
+ _("Link Quality"), ni.wi_quality_level,
+ _("Signal / Noise"),
+ ni.wi_signal_level, _("dBm"),
+ ni.wi_noise_level, _("dBm"),
wifi_bars(ni.wi_signal_level, ni.wi_noise_level));
g_free(txpower);
@@ -456,13 +469,15 @@ static void scan_net_interfaces_24(void)
if (ni.ip[0] || ni.mask[0] || ni.broadcast[0]) {
detailed =
- h_strdup_cprintf("\n[Internet Protocol (IPv4)]\n"
- "IP Address=%s\n" "Mask=%s\n"
- "Broadcast Address=%s\n", detailed,
- ni.ip[0] ? ni.ip : "Not set",
- ni.mask[0] ? ni.mask : "Not set",
- ni.broadcast[0] ? ni.
- broadcast : "Not set");
+ h_strdup_cprintf("\n[%s]\n"
+ "%s=%s\n"
+ "%s=%s\n"
+ "%s=%s\n", detailed,
+ _("Internet Protocol (IPv4)"),
+ _("IP Address"), ni.ip[0] ? ni.ip : _("(Not set)"),
+ _("Mask"), ni.mask[0] ? ni.mask : _("(Not set)"),
+ _("Broadcast Address"),
+ ni.broadcast[0] ? ni.broadcast : _("(Not set)") );
}
moreinfo_add_with_prefix("NET", devid, detailed);