From 60afceb15ab1c9c6957567c73aca55d0570587a6 Mon Sep 17 00:00:00 2001 From: lysec Date: Thu, 16 Oct 2025 11:39:43 +0200 Subject: [PATCH] Battery.qml: replace hardcoded strings with i18n (fixes #497) --- Assets/Translations/de.json | 5 +++++ Assets/Translations/en.json | 5 +++++ Assets/Translations/es.json | 5 +++++ Assets/Translations/fr.json | 5 +++++ Assets/Translations/pt.json | 5 +++++ Assets/Translations/zh-CN.json | 5 +++++ Modules/Bar/Widgets/Battery.qml | 17 +++++++++-------- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index 72b59d78..34bd7764 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -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}%)", diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 7ea6c7cc..5603af49 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -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}%)", diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index fe04122f..67bb2d0f 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -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}%)", diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index 96d668d2..3533f3a1 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -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}%)", diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index 55121c93..61eba991 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -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", diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index 884d6cc1..20aa587b 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -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}%)", diff --git a/Modules/Bar/Widgets/Battery.qml b/Modules/Bar/Widgets/Battery.qml index 47676cdb..ec307841 100644 --- a/Modules/Bar/Widgets/Battery.qml +++ b/Modules/Bar/Widgets/Battery.qml @@ -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") }