Skip to content

fix: return the key for a missing translation in the default locale too - #32

Merged
trakhimenok merged 1 commit into
mainfrom
translate-missing-key-default-locale
Sep 10, 2026
Merged

fix: return the key for a missing translation in the default locale too#32
trakhimenok merged 1 commit into
mainfrom
translate-missing-key-default-locale

Conversation

@trakhimenok

Copy link
Copy Markdown
Member

Why

mapTranslator._translate returned the key for a missing translation in every locale except the default one, where it returned "". sneat-co/sneat-bots passed a bot's raw description through Translate with an en-UK translator whose default is en-UK, so @SneatBot published an empty default description on 2026-09-10 while Russian showed the English text. Founder decision the same day: "improve strongo/i18n if needed".

What

The default-locale branch now returns the key, matching the non-default branch. The two tests that asserted "" ("Key not found", "Non-existent key") now expect the key; a new test covers default and non-default locales for Translate and TranslateNoWarning. No caller in sneat-bots, sneat-go, debtus, sneat-go-core, bots-fw or bots-fw-telegram compares a translation result to the empty string.

Validation

wb run -- go vet ./...
wb run -- go test -count=1 ./...   # ok (i18n, mock_i18n)

🤖 Generated with Claude Code

A missing key came back as the key for every locale except the
translator's own default, where a missing map entry yielded "". Callers
that pass raw copy through Translate (bot profile descriptions) therefore
got empty text exactly when the requested locale was the default one, and
the failure was invisible in every other language. Both branches now
return the key; the two tests that pinned the empty string are updated and
a regression test covers default and non-default locales.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@trakhimenok
trakhimenok merged commit 193a6e3 into main Sep 10, 2026
6 checks passed
@trakhimenok
trakhimenok deleted the translate-missing-key-default-locale branch September 10, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant