diff --git a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala index e58b3a2fe..75bdad803 100644 --- a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala +++ b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala @@ -11,6 +11,6 @@ public class Monitor.IndicatorWidgetBandwidth : Monitor.IndicatorWidget { public override void update_label (Value value) { uint64 bandwidth = value.get_uint64 (); - label.label = format_size (bandwidth); + label.label = Utils.Strings.format_network_speed (bandwidth); } } diff --git a/src/Utils.vala b/src/Utils.vala index 6a8cfe1d0..379fa66e6 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -4,6 +4,8 @@ */ namespace Monitor.Utils { + const int BITS_IN_BYTES = 8; + const string NOT_AVAILABLE = (_("N/A")); const string NO_DATA = "\u2014"; @@ -49,6 +51,14 @@ public class Monitor.Utils.Strings { return pretty; } + public static string format_network_speed (uint64 speed) { + ///TRANSLATORS: The first param is the numeric value (as string) of network speed. + ///The second param with the appended "/s" is the network speed unit such as "Mb/s" for megabits per second. + return _("%s %s/s").printf ( + format_size (speed * Utils.BITS_IN_BYTES, BITS | IEC_UNITS | ONLY_VALUE), + format_size (speed * Utils.BITS_IN_BYTES, BITS | ONLY_UNIT) + ); + } } public class Monitor.Utils.Colors : Object { diff --git a/src/Views/SystemView/SystemNetworkView.vala b/src/Views/SystemView/SystemNetworkView.vala index 1a4c5ef6e..dd5d1fb7d 100644 --- a/src/Views/SystemView/SystemNetworkView.vala +++ b/src/Views/SystemView/SystemNetworkView.vala @@ -60,8 +60,8 @@ public class Monitor.SystemNetworkView : Gtk.Grid { double up_bytes = network.bytes_out; double down_bytes = network.bytes_in; if (up_bytes >= 0 && down_bytes >= 0) { - network_download_label.text = ("%s/s").printf (format_size ((uint64) down_bytes, IEC_UNITS)); - network_upload_label.text = ("%s/s").printf (format_size ((uint64) up_bytes, IEC_UNITS)); + network_download_label.text = Utils.Strings.format_network_speed ((uint64) down_bytes); + network_upload_label.text = Utils.Strings.format_network_speed ((uint64) up_bytes); network_chart.update (0, up_bytes); network_chart.update (1, down_bytes); }