Bugfix Issue 1440 Introduction Background i18n - sebiboga/testlink-upgraded GitHub Wiki
Bugfix β Issue #1440: Test Strategy "Introduction & Background" shows literal i18n keys outside en/ro
Problem
The Introduction & Background chapter page of the Test Strategy
(gui/templates/strategy/intro.html) is fully functional β it opens from the
ASIDE sub-menu ("Test Strategy β Introduction"), from the hub
testStrategy.html (chapter 1 card, Open chapter button) and renders the
two content cards (Purpose of the document / Background) β but for the
8 locales other than English and Romanian it displayed raw i18n keys instead
of text.
Impact (reproduced in browser):
?locale=derendered document titlets.introHeader, headerts.introHeader, subts.introHeaderSub, card titles/bulletsts.introC1Title,ts.introC1a/b/c,ts.introC2Title,ts.introC2a/b/c.- The hub keys (
ts.chapterIntro), the back-link (ts.backToStrategy) and the footer title (ts.header) translated fine in German β only the intro content strings broke. - English and Romanian rendered correctly.
Repro (browser):
http://localhost:8082/login.php, sign inadmin/admin.- ASIDE β Test Strategy β Introduction (or hub β chapter 1 β Open chapter).
- In the mainframe, switch the locale switcher to German (or open
intro.html?locale=dedirectly).
Root Cause
gui/templates/strategy/intro.html defines every visible string with
data-i18n="ts.intro*" (lines 7, 29-30, 42, 44-46, 50, 52-54, 59).
TLi18n.apply() (gui/templates/i18n/i18n.js:148-153) writes
TLi18n.t(key) into each element, and t() returns _strings[key] || key
(i18n.js:134-135) β for a missing key it returns the literal key string
(dev-visible by design).
The content keys ts.introHeader, ts.introHeaderSub, ts.introC1Title,
ts.introC1a/b/c, ts.introC2Title, ts.introC2a/b/c existed only in
en.json (lines 3364-3373) and ro.json (same lines). The other eight
bundles (de/es/fr/it/ja/pt/ru/zh.json) had only the hub keys
(ts.chapterIntro / ts.chapterIntroDesc), so loading de.json and applying
the translations left the intro strings as literal keys.
Blast radius: the Introduction & Background page (issue #1440). The identical missing-key defect exists on the 19 sibling chapter pages β tracked separately in #1486 (bug) so each chapter issue closes only its own keys; the fix pattern here is the reference implementation for it.
Fix
Branch fix/issue-1440, commit cbb2920f5
(fix(strategy): translate Introduction & Background content keys in all 8 non-en/ro bundles (Refs #1440)) β 8 files, +10 lines each (de, es,
fr, it, ja, pt, ru, zh).
For every bundle, the 10 ts.intro* content keys were inserted immediately
after the existing ts.chapterIntroDesc entry, with native translations that
reuse the wording already approved in that bundle's hub key
(ts.chapterIntro/ts.chapterIntroDesc) so the hub card and the chapter page
agree. Example (German):
"ts.introHeader": "Einleitung & Hintergrund",
"ts.introHeaderSub": "Kontext und Zweck des Teststrategie-Dokuments",
"ts.introC1Title": "Zweck des Dokuments",
"ts.introC1a": "Definiert den allgemeinen QualitΓ€ts- und Testansatz fΓΌr das Produkt.",
...
Why this method: minimal and i18n-complete. The page already used TLi18n;
nothing in HTML/JS needed to change. Only the 8 bundles that missed the keys
were touched; en.json/ro.json were already correct and left untouched.
Every bundle was validated with python3 -m json.tool before commit.
Rejected alternatives: (a) removing data-i18n and reverting to hard-coded
English β would drop the translations that do exist; (b) changing
TLi18n.t() to fall back to the element's HTML default β a global behavioral
change affecting ~100 modernized screens; (c) translating only German β would
leave 7 locales broken.
Files Changed
- 8Γ
gui/templates/i18n/{de,es,fr,it,ja,pt,ru,zh}.jsonβ +10 translatedts.intro*keys each (80 lines total). tmp/TLU_Test_Cases.mdβ regression suite "Regression β Issue #1440" (15 cases, 15/15 PASS).docs/Bugfix-Issue-1440-Introduction-Background-i18n.mdβ this write-up (mirror, without image lines).CHANGELOGβ one line under the 2.0.1 key-bugfix section (Refs #1440).
Screenshots
- German (fixed) β
intro.html?locale=derenders "Einleitung & Hintergrund" with fully translated cards. - Chinese (fixed) β
intro.html?locale=zhrenders "εΌθ¨δΈθζ―" with fully translated cards.
Verification
Post-fix: ?locale=<de,es,fr,it,ja,pt,ru,zh> each render the title, header,
sub, both cards and all 6 bullets in the target language with zero literal
ts.intro* keys (verified in headless Chrome); en and ro unchanged and
still correct. All 10 bundles contain all 10 ts.intro* keys exactly once and
pass python3 -m json.tool. events table: no new ERROR/WARNING rows; browser
console clean on every locale. Full matrix: tmp/TLU_Test_Cases.md suite 1440
(15/15 PASS).