From 6c0225061af63031b5f39f9448e6f994be03d9ff Mon Sep 17 00:00:00 2001 From: Peter Siegmund Date: Sat, 11 Apr 2026 20:00:42 +0200 Subject: [PATCH] translations within jscript Signed-off-by: Peter Siegmund --- plugin/actions/GiteaPRAction.js | 4 ++-- plugin/actions/ModelRailwayAction.js | 10 +++++----- plugin/actions/PetrolAction.js | 2 +- plugin/app.js | 3 +++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/plugin/actions/GiteaPRAction.js b/plugin/actions/GiteaPRAction.js index 611fef3..b83817d 100644 --- a/plugin/actions/GiteaPRAction.js +++ b/plugin/actions/GiteaPRAction.js @@ -106,7 +106,7 @@ class GiteaPRAction extends ActionBase { // Label — top ctx.fillStyle = '#7ec8e3'; ctx.font = 'bold 22px "Source Han Sans SC"'; - ctx.fillText('Pull Requests', 98, 30); + ctx.fillText(this.$UD.t('Pull Requests'), 98, 30); if (count === null) { ctx.fillStyle = isError ? '#ff6b6b' : '#888888'; @@ -117,7 +117,7 @@ class GiteaPRAction extends ActionBase { ctx.textBaseline = 'middle'; ctx.fillStyle = isError ? '#ff6b6b' : '#888888'; ctx.font = 'bold 22px "Source Han Sans SC"'; - ctx.fillText(isError ? 'API Error' : 'Offline', 98, 166); + ctx.fillText(isError ? this.$UD.t('API Error') : this.$UD.t('Offline'), 98, 166); } else { const filter = this.config.filter || 'review_requested'; const label = filter === 'assigned' ? 'assigned' : filter === 'review_requested' ? 'review req.' : 'open'; diff --git a/plugin/actions/ModelRailwayAction.js b/plugin/actions/ModelRailwayAction.js index 43ede2e..ab04514 100644 --- a/plugin/actions/ModelRailwayAction.js +++ b/plugin/actions/ModelRailwayAction.js @@ -123,9 +123,9 @@ class ModelRailwayAction extends ActionBase { modeLabel(mode) { switch (mode) { - case 'day': return 'Tag'; - case 'night': return 'Nacht'; - case 'simulation': return 'Simulation'; + case 'day': return this.$UD.t('Day'); + case 'night': return this.$UD.t('Night'); + case 'simulation': return this.$UD.t('Simulation'); default: return mode || '---'; } } @@ -160,11 +160,11 @@ class ModelRailwayAction extends ActionBase { if (!connected) { ctx.fillStyle = '#ff6b6b'; ctx.font = '22px "Source Han Sans SC"'; - ctx.fillText(this.config.host ? 'Verbinde…' : 'Kein Host', 98, 162); + ctx.fillText(this.config.host ? this.$UD.t('Connecting…') : this.$UD.t('No Host'), 98, 162); } else if (!this.lightOn) { ctx.fillStyle = '#888888'; ctx.font = '26px "Source Han Sans SC"'; - ctx.fillText('Aus', 98, 162); + ctx.fillText(this.$UD.t('Off'), 98, 162); } else { ctx.fillStyle = this.modeColor(this.mode); ctx.font = '24px "Source Han Sans SC"'; diff --git a/plugin/actions/PetrolAction.js b/plugin/actions/PetrolAction.js index 9915194..22552bb 100644 --- a/plugin/actions/PetrolAction.js +++ b/plugin/actions/PetrolAction.js @@ -91,7 +91,7 @@ class PetrolAction extends ActionBase { ctx.fillStyle = '#888888'; ctx.font = '22px "Source Han Sans SC"'; - ctx.fillText('Last Rised', 98, 143); + ctx.fillText(this.$UD.t('Last Rised'), 98, 143); ctx.fillStyle = '#ff6b6b'; ctx.font = 'bold 30px "Source Han Sans SC"'; ctx.fillText(`${lastRised.toFixed(3)}€`, 98, 168); diff --git a/plugin/app.js b/plugin/app.js index 08a0561..819bf5c 100644 --- a/plugin/app.js +++ b/plugin/app.js @@ -3,6 +3,9 @@ const ACTION_CACHES = {}; $UD.connect('dev.mars3142.ulanzideck.collection'); $UD.onConnected(() => { console.log('app.js onConnected'); + Utils.readJson(`${Utils.getPluginPath()}/${$UD.language}.json`) + .then(json => { $UD.localization = json['Localization'] || null; }) + .catch(() => {}); }); $UD.onAdd(jsn => {