mirror of https://github.com/espruino/BangleApps
weather - autotranslate strings
parent
fb721b00a7
commit
ee21d0bb48
|
@ -17,4 +17,6 @@
|
||||||
0.18: Added hasRange to clkinfo.
|
0.18: Added hasRange to clkinfo.
|
||||||
0.19: Added weather condition to clkinfo.
|
0.19: Added weather condition to clkinfo.
|
||||||
0.20: Added weather condition with temperature to clkinfo.
|
0.20: Added weather condition with temperature to clkinfo.
|
||||||
0.21: Updated clkinfo icon.
|
0.21: Updated clkinfo icon.
|
||||||
|
0.22: Automatic translation of strings, some left untranslated.
|
||||||
|
>>>>>>> b37fcacd1 (weather - autotranslate strings)
|
||||||
|
|
|
@ -16,10 +16,10 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
|
||||||
{type: "txt", font: "12%", valign: -1, id: "tempUnit", label: "°C"},
|
{type: "txt", font: "12%", valign: -1, id: "tempUnit", label: "°C"},
|
||||||
]},
|
]},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
{type: "txt", font: "6x8", pad: 2, halign: 1, label: "Humidity"},
|
{type: "txt", font: "6x8", pad: 2, halign: 1, label: /*LANG*/"Humidity"},
|
||||||
{type: "txt", font: "9%", pad: 2, halign: 1, id: "hum", label: "000%"},
|
{type: "txt", font: "9%", pad: 2, halign: 1, id: "hum", label: "000%"},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
{type: "txt", font: "6x8", pad: 2, halign: -1, label: "Wind"},
|
{type: "txt", font: "6x8", pad: 2, halign: -1, label: /*LANG*/"Wind"},
|
||||||
{type: "h", halign: -1, c: [
|
{type: "h", halign: -1, c: [
|
||||||
{type: "txt", font: "9%", pad: 2, id: "wind", label: "00"},
|
{type: "txt", font: "9%", pad: 2, id: "wind", label: "00"},
|
||||||
{type: "txt", font: "6x8", pad: 2, valign: -1, id: "windUnit", label: "km/h"},
|
{type: "txt", font: "6x8", pad: 2, valign: -1, id: "windUnit", label: "km/h"},
|
||||||
|
@ -27,22 +27,22 @@ var layout = new Layout({type:"v", bgCol: g.theme.bg, c: [
|
||||||
]},
|
]},
|
||||||
]},
|
]},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
{type: "txt", font: "9%", wrap: true, height: g.getHeight()*0.18, fillx: 1, id: "cond", label: "Weather condition"},
|
{type: "txt", font: "9%", wrap: true, height: g.getHeight()*0.18, fillx: 1, id: "cond", label: /*LANG*/"Weather condition"},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
{type: "h", c: [
|
{type: "h", c: [
|
||||||
{type: "txt", font: "6x8", pad: 4, id: "loc", label: "Toronto"},
|
{type: "txt", font: "6x8", pad: 4, id: "loc", label: "Toronto"},
|
||||||
{fillx: 1},
|
{fillx: 1},
|
||||||
{type: "txt", font: "6x8", pad: 4, id: "updateTime", label: "15 minutes ago"},
|
{type: "txt", font: "6x8", pad: 4, id: "updateTime", label: /*LANG*/"15 minutes ago"},
|
||||||
]},
|
]},
|
||||||
{filly: 1},
|
{filly: 1},
|
||||||
]}, {lazy: true});
|
]}, {lazy: true});
|
||||||
|
|
||||||
function formatDuration(millis) {
|
function formatDuration(millis) {
|
||||||
let pluralize = (n, w) => n + " " + w + (n == 1 ? "" : "s");
|
let pluralize = (n, w) => n + " " + w + (n == 1 ? "" : "s");
|
||||||
if (millis < 60000) return "< 1 minute";
|
if (millis < 60000) return /*LANG*/"< 1 minute";
|
||||||
if (millis < 3600000) return pluralize(Math.floor(millis/60000), "minute");
|
if (millis < 3600000) return pluralize(Math.floor(millis/60000), /*LANG*/"minute");
|
||||||
if (millis < 86400000) return pluralize(Math.floor(millis/3600000), "hour");
|
if (millis < 86400000) return pluralize(Math.floor(millis/3600000), /*LANG*/"hour");
|
||||||
return pluralize(Math.floor(millis/86400000), "day");
|
return pluralize(Math.floor(millis/86400000), /*LANG*/"day");
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
|
@ -57,7 +57,7 @@ function draw() {
|
||||||
layout.windUnit.label = wind[2] + " " + (current.wrose||'').toUpperCase();
|
layout.windUnit.label = wind[2] + " " + (current.wrose||'').toUpperCase();
|
||||||
layout.cond.label = current.txt.charAt(0).toUpperCase()+(current.txt||'').slice(1);
|
layout.cond.label = current.txt.charAt(0).toUpperCase()+(current.txt||'').slice(1);
|
||||||
layout.loc.label = current.loc;
|
layout.loc.label = current.loc;
|
||||||
layout.updateTime.label = `${formatDuration(Date.now() - current.time)} ago`;
|
layout.updateTime.label = `${formatDuration(Date.now() - current.time)} ago`; // How to autotranslate this and similar?
|
||||||
layout.update();
|
layout.update();
|
||||||
layout.render();
|
layout.render();
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,9 @@ function update() {
|
||||||
} else {
|
} else {
|
||||||
layout.forgetLazyState();
|
layout.forgetLazyState();
|
||||||
if (NRF.getSecurityStatus().connected) {
|
if (NRF.getSecurityStatus().connected) {
|
||||||
E.showMessage("Weather\nunknown\n\nIs Gadgetbridge\nweather\nreporting set\nup on your\nphone?");
|
E.showMessage(/*LANG*/"Weather\nunknown\n\nIs Gadgetbridge\nweather\nreporting set\nup on your\nphone?");
|
||||||
} else {
|
} else {
|
||||||
E.showMessage("Weather\nunknown\n\nGadgetbridge\nnot connected");
|
E.showMessage(/*LANG*/"Weather\nunknown\n\nGadgetbridge\nnot connected");
|
||||||
NRF.on("connect", update);
|
NRF.on("connect", update);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "weather",
|
"id": "weather",
|
||||||
"name": "Weather",
|
"name": "Weather",
|
||||||
"version": "0.21",
|
"version": "0.22",
|
||||||
"description": "Show Gadgetbridge weather report",
|
"description": "Show Gadgetbridge weather report",
|
||||||
"icon": "icon.png",
|
"icon": "icon.png",
|
||||||
"screenshots": [{"url":"screenshot.png"}],
|
"screenshots": [{"url":"screenshot.png"}],
|
||||||
|
|
Loading…
Reference in New Issue