From 0f26de9222ca62e3a517f01d2d24bf988d35e96a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 2 Jun 2026 01:31:18 +0000 Subject: [PATCH] Use translation keys for all FX row labels; append currency dynamically MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All four FX sub-row labels now come from config translations instead of hardcoded English strings. Labels with a currency suffix (per-item, total-foreign) have the currency code appended by updateFxLabels() so they read e.g. "Price per item in USD" / "Line total in USD" and update when the foreign currency dropdown changes. Language switching also re-applies all four labels via the existing updateFxLabels() call in relabel(). Translation key values updated: - currency-code → "Foreign currency code" - exchange-rate → "Exchange rate" (dropped the redundant convention note) - per-item → "Price per item in" (currency appended at runtime) - total-foreign → "Line total in" (currency appended at runtime) PDF note updated to match: "Price per item in USD: 100.00 (35 THB per USD)" https://claude.ai/code/session_0151QtsUhzXmgzEhSvXG2SDt --- app/config.yml | 32 ++++++++++++++++---------------- app/index.html | 22 ++++++++++++++-------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/config.yml b/app/config.yml index 06b717a..275ee1d 100644 --- a/app/config.yml +++ b/app/config.yml @@ -408,25 +408,25 @@ translations: fr: Devise étrangère "no": Utenlandsk valuta currency-code: - en: Currency code - de: Währungscode - fr: Code devise - "no": Valutakode + en: Foreign currency code + de: Fremdwährungscode + fr: Code devise étrangère + "no": Utenlandsk valutakode exchange-rate: - en: "Exchange rate (1 foreign = X local)" - de: "Wechselkurs (1 Fremd = X Inland)" - fr: "Taux de change (1 étranger = X local)" - "no": "Valutakurs (1 utenlandsk = X lokal)" + en: Exchange rate + de: Wechselkurs + fr: Taux de change + "no": Valutakurs per-item: - en: Price per item (foreign currency) - de: Preis je Einheit (Fremdwährung) - fr: Prix par unité (devise étrangère) - "no": Pris per enhet (utenlandsk valuta) + en: Price per item in + de: Preis je Einheit in + fr: Prix par unité en + "no": Pris per enhet i total-foreign: - en: Line total in foreign currency - de: Zeilenbetrag (Fremdwährung) - fr: Total ligne en devise étrangère - "no": Linjebeløp i utenlandsk valuta + en: Line total in + de: Zeilenbetrag in + fr: Total ligne en + "no": Linjebeløp i add-line: en: "+ Add new line" de: "+ Neue Zeile hinzufügen" diff --git a/app/index.html b/app/index.html index 3abcfec..2d2853f 100644 --- a/app/index.html +++ b/app/index.html @@ -931,11 +931,11 @@ function toggleFx(i) {
-
${t("currency-code")}
+
${t("currency-code")}
-
Exchange rate
+
${t("exchange-rate")}
-
${t("total-foreign")}: 0.00
+
${t("total-foreign")} ${h(defaultFcy)}: 0.00
`; lr?.insertAdjacentElement("afterend", fxTr); calcLine(i); @@ -1406,7 +1406,7 @@ function buildPDF() { let fxH = 0; if (row.fxNote) { const fxOther = row.fxNote.rcur === iCur ? row.fxNote.cur : iCur; - const fxStr = `${td("per-item")}: ${row.fxNote.cur} ${fmt(row.fxNote.per)} ` + const fxStr = `${td("per-item")} ${row.fxNote.cur}: ${fmt(row.fxNote.per)} ` + `(${(+row.fxNote.rate).toFixed(5)} ${row.fxNote.rcur} per ${fxOther})`; const fxLines = sp(fxStr, CD + CP - 4); fxH = fxLines.length * 3.5 + 1; @@ -1440,7 +1440,7 @@ function buildPDF() { if (row.fxNote) { const fxOther = row.fxNote.rcur === iCur ? row.fxNote.cur : iCur; - const fxStr = `${td("per-item")}: ${row.fxNote.cur} ${fmt(row.fxNote.per)} ` + const fxStr = `${td("per-item")} ${row.fxNote.cur}: ${fmt(row.fxNote.per)} ` + `(${(+row.fxNote.rate).toFixed(5)} ${row.fxNote.rcur} per ${fxOther})`; fn(7); tc(107,114,128); const fxLines = sp(fxStr, CD + CP - 4); @@ -1491,14 +1491,20 @@ function updateFxLabels(i) { const lcy = document.getElementById("icur")?.value || ""; const rcurEl = document.getElementById(`rcur-${i}`); const rotherEl = document.getElementById(`rother-${i}`); - const pl = document.getElementById(`fper-lbl-${i}`); if (rcurEl) { const prev = rcurEl.value; rcurEl.innerHTML = ``; rcurEl.value = (prev === lcy || prev === fcy) ? prev : lcy; } if (rotherEl) rotherEl.textContent = rcurEl?.value === lcy ? fcy : lcy; - if (pl) pl.textContent = `Price per item in ${fcy}`; + const cl = document.getElementById(`fcur-lbl-${i}`); + if (cl) cl.textContent = t("currency-code"); + const rl = document.getElementById(`frate-lbl-${i}`); + if (rl) rl.textContent = t("exchange-rate"); + const pl = document.getElementById(`fper-lbl-${i}`); + if (pl) pl.textContent = t("per-item") + " " + fcy; + const tl = document.getElementById(`ftot-lbl-${i}`); + if (tl) tl.textContent = t("total-foreign") + " " + fcy; } // ── Save / load invoice lines ──────────────────────────────────────────────────