Skip to content

backlog: fix reaction-prompt-i18n snippet to project convention#40

Merged
vladmesh merged 1 commit into
mainfrom
chore/backlog-reaction-i18n-snippet
Jul 16, 2026
Merged

backlog: fix reaction-prompt-i18n snippet to project convention#40
vladmesh merged 1 commit into
mainfrom
chore/backlog-reaction-i18n-snippet

Conversation

@vladmesh

Copy link
Copy Markdown
Owner

Follow-up to #39. The entry suggested %-interpolation:

_("Melee attack against %(target)s") % {...}

That works, but contradicts the codebase: handlers use _("Item {id} not in inventory").format(id=item_id) and the .po msgids carry {} placeholders. Left as-is it would send whoever picks this up down the wrong path. Now:

_("Melee attack against {target}").format(target=mover.name)

Also spells out why wrapping _() at the transport layer fails, which the original entry only asserted:

  • fallback=True in i18n.py means a missed msgid returns the input string unchanged, silently — no error, tests stay green, the player sees English
  • the catalog is built by statically scanning literals inside _(), so there is nothing to extract from an f-string; make messages additionally falls over on f-strings
  • notes that _() resolves via the current_lang contextvar (per-session), which a transport-layer wrap would not give

Docs-only change.

The suggested snippet used %-interpolation; the codebase uses
_("... {id} ...").format(id=...) and the .po msgids carry {} placeholders.
Also spell out why wrapping _() at transport fails silently: fallback=True
returns the msgid unchanged, and pygettext cannot extract from an f-string.
@vladmesh
vladmesh enabled auto-merge July 16, 2026 17:42
@vladmesh
vladmesh merged commit 9afef95 into main Jul 16, 2026
4 checks passed
@vladmesh
vladmesh deleted the chore/backlog-reaction-i18n-snippet branch July 16, 2026 17:43
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