Support #223
closedI18N | sk fallback, translation health check, and the missing-translation report
Description
Three defects that all render as the same symptom — a blank button, label or paragraph — and all come
from the same root cause in two different systems: a translation value that exists but is an empty string
does not trigger a fallback.
UI strings. DatabaseTranslationLoader::load() ends with $lines[$key] = $values[$locale] ?? '';.
The ?? only catches an absent locale. A row stored as {"sk":"Prejsť k pokladni","en":"","ru":""}
returns '' on /en/ and /ru/, and the button renders with no text. This is not hypothetical — migration
2026_09_07_000001_fix_go_to_checkout_translation.php exists precisely because that exact row shipped that
way, and its down() restores the empty strings verbatim.
Catalogue content. The identical bug, one layer down and not previously identified.
spatie/laravel-translatable's normalizeLocale() decides whether to fall back with
in_array($locale, $translatedLocales), where $translatedLocales is array_keys($translations) — so a
present-but-empty locale key satisfies the check and the fallback never runs. Product::getName() then
does ?: null on the empty result. A product whose name JSON is {"sk":"Kytica","en":""} renders a
nameless card on /en/. config/app.php already sets fallback_locale => sk; it is bypassed, not absent,
so publishing config/translatable.php would not fix it.
Fix both: fall back to sk whenever the requested locale's value is empty, not merely missing. The fallback
applies to every row unconditionally — rendering Slovak is always better than rendering nothing.
The guard. A new translations:check command, with a deliberate severity split:
fails on an empty sk value (nothing left to fall back to — a guaranteed blank) and warns on an empty
en/ru (the fallback covers it; it is a content gap, not a defect). Wired into deploy:update as a
warning only — a production deploy blocked over a missing Russian string is a worse outcome than the
missing string. Mirrored by a PHPUnit test that fails, so the developer is gated even though the deploy
is not. Note there is no CI test stage, by decision — see the QA ticket.
Scope of the catalogue check: Product::scopeVisible() — which includes status='out_of_stock', since
those still render their name on cards and detail pages. The two deliberately-unfinished inactive products
are excluded by that scope.
The report (todo item 1) — read this before starting it. The deliverable is
.myNotes/missing-translations-2026-09-20.md, and the important finding is that it cannot be produced
from this repo. Every empty value in database/data/website-translations.json is either a search keyword
or an orphan; zero rendered keys are empty in the fixture. The defect exists only in production's
translations table, which has drifted from the fixture (the fix_go_to_checkout migration is the proof).
No production database access is used or wanted. The agreed process: the shop owner supplies the key list
from the CMS "Переводы" module, and the report answers each key with proposed sk/en/ru text plus
the URL and the on-screen element to look at — no file paths, because the point is visual confirmation
on the live site. Keys that cannot be located on any page are reported as orphans, which is how the orphan
sweep gets done at the same time.
Branch: fix/translation-fallback-and-check