Battery.qml: replace hardcoded strings with i18n (fixes #497)

This commit is contained in:
lysec
2025-10-16 11:39:43 +02:00
parent a1aa162e3f
commit 60afceb15a
7 changed files with 39 additions and 8 deletions
+5
View File
@@ -1445,6 +1445,11 @@
"discharging-rate": "Entladerate: {rate} W.",
"charging": "Wird geladen.",
"discharging": "Wird entladen.",
"plugged-in": "Angeschlossen.",
"idle": "Leerlauf.",
"time-left": "Verbleibende Zeit: {time}.",
"time-until-full": "Zeit bis vollständig geladen: {time}.",
"health": "Zustand: {percent}%",
"panel": {
"title": "Ladeschwelle",
"full": "Volle Kapazität ({percent}%)",
+5
View File
@@ -1616,6 +1616,11 @@
"discharging-rate": "Discharging rate: {rate} W.",
"charging": "Charging.",
"discharging": "Discharging.",
"plugged-in": "Plugged in.",
"idle": "Idle.",
"time-left": "Time left: {time}.",
"time-until-full": "Time until full: {time}.",
"health": "Health: {percent}%",
"panel": {
"title": "Charge threshold",
"full": "Full capacity ({percent}%)",
+5
View File
@@ -1616,6 +1616,11 @@
"discharging-rate": "Tasa de descarga: {rate} W.",
"charging": "Cargando.",
"discharging": "Descargando.",
"plugged-in": "Conectado.",
"idle": "Inactivo.",
"time-left": "Tiempo restante: {time}.",
"time-until-full": "Tiempo hasta carga completa: {time}.",
"health": "Salud: {percent}%",
"panel": {
"title": "Umbral de carga",
"full": "Capacidad total ({percent}%)",
+5
View File
@@ -1616,6 +1616,11 @@
"discharging-rate": "Taux de décharge : {rate} W.",
"charging": "En charge.",
"discharging": "En décharge.",
"plugged-in": "Branché.",
"idle": "Inactif.",
"time-left": "Temps restant : {time}.",
"time-until-full": "Temps jusqu'à charge complète : {time}.",
"health": "État : {percent}%",
"panel": {
"title": "Seuil de charge",
"full": "Capacité totale ({percent}%)",
+5
View File
@@ -1616,6 +1616,11 @@
"discharging-rate": "Taxa de descarregamento: {rate} W.",
"charging": "Carregando.",
"discharging": "Descarregando.",
"plugged-in": "Conectado.",
"idle": "Ocioso.",
"time-left": "Tempo restante: {time}.",
"time-until-full": "Tempo até carga completa: {time}.",
"health": "Saúde: {percent}%",
"panel": {
"balanced": "Balanceado ({percent}%)",
"disabled": "Gerenciador de bateria desativado",
+5
View File
@@ -1616,6 +1616,11 @@
"discharging-rate": "放电速率:{rate} W。",
"charging": "正在充电。",
"discharging": "正在放电。",
"plugged-in": "已接通电源。",
"idle": "空闲。",
"time-left": "剩余时间:{time}。",
"time-until-full": "充满所需时间:{time}。",
"health": "健康状况:{percent}%",
"panel": {
"title": "充电阈值",
"full": "完全容量 ({percent}%)",
+9 -8
View File
@@ -103,28 +103,29 @@ Item {
return lines.join("\n")
}
if (!isReady || !battery.isLaptopBattery) {
return "No battery detected."
return I18n.tr("battery.no-battery-detected")
}
if (battery.timeToEmpty > 0) {
lines.push(`Time left: ${Time.formatVagueHumanReadableDuration(battery.timeToEmpty)}.`)
lines.push(I18n.tr("battery.time-left", {"time": Time.formatVagueHumanReadableDuration(battery.timeToEmpty)}))
}
if (battery.timeToFull > 0) {
lines.push(`Time until full: ${Time.formatVagueHumanReadableDuration(battery.timeToFull)}.`)
lines.push(I18n.tr("battery.time-until-full", {"time": Time.formatVagueHumanReadableDuration(battery.timeToFull)}))
}
if (battery.changeRate !== undefined) {
const rate = battery.changeRate
if (rate > 0) {
lines.push(charging ? "Charging rate: " + rate.toFixed(2) + " W." : "Discharging rate: " + rate.toFixed(2) + " W.")
lines.push(charging ? I18n.tr("battery.charging-rate", {"rate": rate.toFixed(2)}) : I18n.tr("battery.discharging-rate", {"rate": rate.toFixed(2)}))
} else if (rate < 0) {
lines.push("Discharging rate: " + Math.abs(rate).toFixed(2) + " W.")
lines.push(I18n.tr("battery.discharging-rate", {"rate": Math.abs(rate).toFixed(2)}))
} else {
lines.push("Estimating...")
// Rate is 0 - check if plugged in (charging state) or idle
lines.push(charging ? I18n.tr("battery.plugged-in") : I18n.tr("battery.idle"))
}
} else {
lines.push(charging ? "Charging." : "Discharging.")
lines.push(charging ? I18n.tr("battery.charging") : I18n.tr("battery.discharging"))
}
if (battery.healthPercentage !== undefined && battery.healthPercentage > 0) {
lines.push("Health: " + Math.round(battery.healthPercentage) + "%")
lines.push(I18n.tr("battery.health", {"percent": Math.round(battery.healthPercentage)}))
}
return lines.join("\n")
}