Skip to content

fix(blocklist/whitelist): localize the export/import failure reasons (#456)#470

Merged
Aybook merged 1 commit into
devfrom
feat/456-blocklist-whitelist-i18n
Jul 18, 2026
Merged

fix(blocklist/whitelist): localize the export/import failure reasons (#456)#470
Aybook merged 1 commit into
devfrom
feat/456-blocklist-whitelist-i18n

Conversation

@Aybook

@Aybook Aybook commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #456.

+blocklist/+whitelist export and import printed their failure reason in English regardless of cfg.language. Both plugins localise every success reason and most failure reasons through a lang template, but three technical failure returns in the JSONL helpers were raw English literals - "open failed: <io error>" (export + import) and "json.encode failed: <error>" (export) - and the dispatcher's reply( msg or tostring( err ) ) surfaced them verbatim.

Correction to the issue (§1a.4)

The issue's table also listed add as affected. Re-derived from source, add was already localised - do_add_entry always returns a utf_format( msg_*, ... ) message - so only the three export/import strings were the real gap.

Fix

  • Two per-reason lang keys, en + de, both plugins: msg_open_failed ("Could not open %s: %s", now also naming the path) and msg_encode_failed ("JSON encode failed: %s"), matching the plugins' existing per-reason localisation convention. The three raw returns route through them.
  • The per-row _sanitize_import_row reasons stay English by design: they go to hub_debug (script log) only, never to the operator reply, which shows the already-localised added/skipped/errors summary.
  • etc_blocklist gains the _do_export_jsonl / _do_import_jsonl test seams its twin etc_whitelist already exported (§1a.1 twin parity).
  • Both plugins v0.02 -> v0.03.

Tests (§1a.7)

etc_blocklist_test.lua (via the real command dispatcher) and etc_whitelist_test.lua (via the seams) - both already registered on each smoke.yml leg - gain cases that force an import open-failure and an export encode-failure and assert the reply renders the template ("Could not open" / "JSON encode failed") and no longer the raw "open failed:" / "json.encode failed:". Four checks per plugin, red on the unpatched code (verified: 4 failures/plugin on HEAD, green patched). plugin_lang_test stays green (4300/4300) with the new keys wired in both languages.

Review (§1a.6)

Independent reviewer + maintainer spot-check: no blockers, no concerns. Verified %s/arg-count parity at all 6 sites (en/de templates match), the de ASCII transliteration, twin parity, that nothing else changed, that the _sanitize_import_row reasons are genuinely operator-invisible, and the tests discriminate (both assertion directions red pre-fix). Lang files stay LF / no-BOM. One CHANGELOG precision NIT folded in (cite #458 for the earlier template removal).

3.2.x only, not backported.

🤖 Generated with Claude Code

…456)

Both plugins render every success reason and most failure reasons
through a lang template, but three technical failure returns in the
JSONL export/import helpers were raw English literals - "open failed:
<io error>" (export + import) and "json.encode failed: <error>"
(export) - and the dispatcher's `reply( msg or tostring( err ) )`
surfaced them verbatim regardless of cfg.language.

(The issue also listed `add` as affected; re-derived from source, `add`
was already localized - do_add_entry always returns a utf_format(msg_*)
message - so only the three export/import strings were the real gap.)

Fixed by adding two per-reason keys, msg_open_failed ("Could not open
%s: %s", now also naming the path) and msg_encode_failed ("JSON encode
failed: %s"), in en + de for both plugins, and routing the three raw
returns through them - matching the plugins' existing per-reason
localization convention. The per-row _sanitize_import_row reasons are
deliberately left English: they route to hub_debug only (script log),
never to the operator reply, which shows the already-localized
added/skipped/errors summary.

Also gave etc_blocklist the _do_export_jsonl / _do_import_jsonl test
seams its twin etc_whitelist already exported (§1a.1 twin parity).
Both plugins v0.02 -> v0.03.

Provably fails pre-fix (§1a.7): etc_blocklist_test.lua (via the real
dispatcher) and etc_whitelist_test.lua (via the seams), both already on
each smoke.yml leg, gain cases that force an import open-failure and an
export encode-failure and assert the reply renders the template
("Could not open" / "JSON encode failed") and no longer the raw
strings - four checks per plugin, red on the unpatched code.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Aybook
Aybook merged commit 95529ec into dev Jul 18, 2026
9 checks passed
@Aybook
Aybook deleted the feat/456-blocklist-whitelist-i18n branch July 18, 2026 16:27
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