Changeset View
Standalone View
applets/systemmonitor/net/contents/ui/net.qml
Show All 33 Lines | 31 | onSourceAdded: { | |||
---|---|---|---|---|---|
34 | } | 34 | } | ||
35 | var match = source.match(/^network\/interfaces\/(\w+)\/transmitter\/data$/); | 35 | var match = source.match(/^network\/interfaces\/(\w+)\/transmitter\/data$/); | ||
36 | if (match) { | 36 | if (match) { | ||
37 | var rxSource = "network/interfaces/" + match[1] + "/receiver/data"; | 37 | var rxSource = "network/interfaces/" + match[1] + "/receiver/data"; | ||
38 | root.addSource(source, match[1], rxSource, match[1]); | 38 | root.addSource(source, match[1], rxSource, match[1]); | ||
39 | } | 39 | } | ||
40 | } | 40 | } | ||
41 | 41 | | |||
42 | delegate: DoublePlotter {} | 42 | function formatBitSpeed(value) { | ||
davidedmundson: formatBitSpeed ?
Otherwise it's confusing | |||||
43 | if (value > (1024 * 1024)) { | ||||
Perhaps explain this "magic number" in a comment? (The more obvious this is, the easier it is to revisit in the future) sebas: Perhaps explain this "magic number" in a comment? (The more obvious this is, the easier it is… | |||||
44 | return i18nc("%1 is the displayed data transfer speed in megabits per second", "%1 Mbps", (value / (1024 * 1024)).toFixed(1)); | ||||
the c in i18nc means "context" so it's used as a description of what the message is for for translators so they know what the string is for, as they can't see the code or where it's used. Repeating the text doesn't help, we want something like "Transfer speed shown on a graph label " davidedmundson: the c in i18nc means "context"
so it's used as a description of what the message is for for… | |||||
nitpick (to expand on David's explanation), the comment is now redundant (the string already gives the unit). The translators need context, often this means telling them where this string is displayed, so they can make a call what the actual translation would be, and test and verify the correctness. (Not super critical, but since we're talking i18nc semantics anyway, I thought it'd be useful to mention.) sebas: nitpick (to expand on David's explanation), the comment is now redundant (the string already… | |||||
45 | } | ||||
46 | if (value > 1024) { | ||||
47 | return i18nc("%1 is the displayed data transfer speed in kilobits per second", "%1 Kbps", (value / 1024)); | ||||
48 | } | ||||
49 | if (value > 0) { | ||||
50 | return i18nc("%1 is the displayed data transfer speed in bits per second", "%1 bps", value); | ||||
51 | } | ||||
52 | return value; | ||||
A context string of "zero" is even more confusing, maybe just return value here. davidedmundson: A context string of "zero" is even more confusing, maybe just return value here.
| |||||
53 | } | ||||
54 | | ||||
55 | delegate: DoublePlotter { | ||||
56 | function formatLabel(data1, data2) { | ||||
57 | return i18nc("%1 and %2 are values of the same datatype", "%1 | %2", formatBitSpeed(data1.value * 1024 * 8), | ||||
58 | formatBitSpeed(data2.value * 1024 * 8)); | ||||
59 | } | ||||
60 | } | ||||
43 | } | 61 | } | ||
44 | No newline at end of file | |
formatBitSpeed ?
Otherwise it's confusing