Skip to content

fix(admin): translate strings in top-10 admin UI files (i18n leaks) - #937

Merged
ascorbic merged 2 commits into
mainfrom
fix/admin-i18n-leaks-v2
May 7, 2026
Merged

ascorbic merged 2 commits into
mainfrom
fix/admin-i18n-leaks-v2

Conversation

@ascorbic

@ascorbic ascorbic commented May 7, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Wraps ~250 user-facing English strings in Lingui's `t` macro across the 10 admin files with the most i18n leaks (per a full audit of `packages/admin/src/`). These strings currently bypass translation entirely and render as English in every locale.

This is the second of a series of stacked PRs cleaning up admin UI inconsistencies. #934 (button consistency) merged first.

Files changed:

  • `router.tsx` — toast titles/descriptions for content/comment mutations (publish, unpublish, schedule, delete, restore, duplicate, translate, bulk actions). Plus `LoadingScreen`, `ErrorScreen`, `NotFoundPage`. Uses `plural()` for the comment-bulk-action message.
  • `ContentTypeEditor.tsx` — Settings/Comments/Fields panels, ConfirmDialog props, badges, save buttons. Module-scope `MODERATION_OPTIONS` converted to a `Record<key, MessageDescriptor>` resolved with `t()` at render. Field-count plural via `` + `plural()`. URL pattern hint uses `${"{slug}"}` interpolation to escape the literal `{slug}` token from ICU placeholder syntax.
  • `Widgets.tsx` — page header, drag/drop empty states, dialog labels, palette item titles, ConfirmDialog props, toast feedback.
  • `PortableTextEditor.tsx` — every `title=` / `aria-label=` on the editor toolbar (Bold, Italic, Underline, Strikethrough, Code, headings, lists, alignment, undo/redo, link/image/HR insert, focus mode toggle).
  • `editor/ImageNode.tsx` — `useLingui` added; quick-edit-alt, image settings, delete, alt-text label/placeholder, save/cancel buttons.
  • `editor/PluginBlockNode.tsx` — `useLingui` added; `getEmbedMeta` helper now returns `MessageDescriptor` (using `msg``) so module-scope code can hold non-translated values.
  • `InviteAcceptPage.tsx` — `useLingui` added across three components; error states, form labels, status messages.
  • `users/UserList.tsx` — table headers, search/filter labels, status badges, empty states, load-more button.
  • `routes/bylines.tsx` — `useLingui` added; full page (search, filters, form labels, save/delete buttons, ConfirmDialog props).
  • `routes/users.tsx` — `useLingui` added; disable/demote ConfirmDialog props.

Sub-tasks were dispatched to sub-agents (Haiku-based `simple-tasks` and Kimi for the larger files); main changes verified with full typecheck + test pass.

This is the first half of the i18n cleanup. The remaining ~40 leaks across 23 files (settings panels, marketplace, sandboxed-plugin host, auth flows, lib/api fallback strings) will follow in a separate stacked PR.

(Replaces #936, which was closed because of stale-base conflicts.)

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • `pnpm typecheck` passes
  • `pnpm lint` passes
  • `pnpm test` passes (admin: 858/858)
  • `pnpm format` has been run
  • I have added/updated tests for my changes (if applicable) — not applicable, all changes are 1:1 string wrapping with no behavior change. Existing test suite covers regressions (one was caught and fixed: ICU placeholder escaping for the literal `{slug}` token).
  • User-visible strings in the admin UI are wrapped for translation. Do not include `messages.po` changes except in translation PRs — a workflow extracts catalogs on merge to `main`.
  • I have added a changeset
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.7 (orchestration) + Claude Haiku 4.5 (`simple-tasks` subagents) + Kimi K2.6 (`kimi-general` subagents) via OpenCode

Screenshots / test output

No visual change in default English locale — strings render identically. Run with `EMDASH_PSEUDO_LOCALE=1` to verify the strings now flow through translation: previously English text leaked through pseudo-localization in these files; after this PR, all listed strings render pseudo-localized.

Stack: `main` → #934 (merged) → this PR → (next: long-tail i18n) → (next: raw HTML to Kumo) → (next: aria-labels) → (next: RTL safety) → (next: semantic tokens) → (last: ESLint enforcement)

Wrap user-facing English strings in Lingui's t macro across the most-used
admin screens: router toasts and error pages, ContentTypeEditor, Widgets,
PortableTextEditor toolbar, ImageNode, PluginBlockNode, InviteAcceptPage,
UserList, routes/users, routes/bylines.

Adds useLingui where missing and converts module-scope label maps to
MessageDescriptor records resolved at render time. Long-tail leaks in
remaining files will follow in a separate PR.
Copilot AI review requested due to automatic review settings May 7, 2026 13:21
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-perf-coordinator 8867274 May 07 2026, 01:21 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-i18n 88febcc May 07 2026, 01:26 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-perf-coordinator 88febcc May 07 2026, 01:26 PM

@changeset-bot

changeset-bot Bot commented May 7, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 88febcc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 635 lines across 11 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 88febcc May 07 2026, 01:26 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 88febcc May 07 2026, 01:27 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 88febcc May 07 2026, 01:27 PM

@pkg-pr-new

pkg-pr-new Bot commented May 7, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@937

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@937

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@937

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@937

emdash

npm i https://pkg.pr.new/emdash@937

create-emdash

npm i https://pkg.pr.new/create-emdash@937

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@937

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@937

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@937

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@937

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@937

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@937

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@937

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@937

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@937

commit: 88febcc

…Descriptor

Plugin placeholders are runtime strings that won't be in the Lingui catalog.
Wrapping them in { id: def.placeholder } caused failed lookups and missing
translation warnings. Split the type so plugin strings render as-is and only
the dev-supplied fallback is translated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes i18n “leaks” in the admin SPA by routing previously hard-coded English UI strings through Lingui macros, improving localization coverage on the most frequently used screens.

Changes:

  • Wraps user-facing strings (including toasts, dialogs, placeholders, titles, and aria-labels) with Lingui t, Trans, and plural across key admin routes/components.
  • Adjusts a few module-scope metadata/constants to store MessageDescriptors (via msg) and resolve them at render time.
  • Adds an admin changeset documenting the localization fixes.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/admin/src/router.tsx Translates router screens and mutation toast strings; adds pluralized bulk-comment toast.
packages/admin/src/components/ContentTypeEditor.tsx Translates labels/help text/dialog copy; introduces MODERATION_OPTIONS as MessageDescriptors; pluralizes field count.
packages/admin/src/components/Widgets.tsx Translates widgets UI copy, dialog labels, empty states, and ARIA labels/toasts.
packages/admin/src/components/PortableTextEditor.tsx Translates toolbar titles/aria-labels and modal strings within the editor UI.
packages/admin/src/components/editor/ImageNode.tsx Translates image node actions and inline alt-text editor labels/placeholders.
packages/admin/src/components/editor/PluginBlockNode.tsx Moves embed placeholder metadata to MessageDescriptor and translates node UI labels.
packages/admin/src/components/InviteAcceptPage.tsx Translates invite-accept flow UI strings and error states.
packages/admin/src/components/users/UserList.tsx Translates list headers, filters, empty states, and status labels.
packages/admin/src/routes/bylines.tsx Translates bylines route UI: filters, labels, empty states, and confirm dialog copy.
packages/admin/src/routes/users.tsx Translates confirm dialog titles/labels and error UI in the users route.
.changeset/tall-flies-vanish.md Adds a patch changeset for the admin package describing the i18n leak fixes.
Comments suppressed due to low confidence (1)

packages/admin/src/components/InviteAcceptPage.tsx:168

  • In InviteAcceptPage's useEffect, t is used to set the error message but isn't included in the dependency array. If the active locale changes while this component is mounted, the effect won't re-run and the stored error string can remain in the old language. Consider adding t (or i18n) to the deps, or derive this message at render time instead of storing the translated string in state.
	React.useEffect(() => {
		if (!urlToken) {
			setError(t`No invite token provided`);
			setStep("error");
			setIsLoading(false);
			return;
		}

		setToken(urlToken);
		void verifyToken(urlToken);
	}, [urlToken]);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Overlapping PRs

This PR modifies files that are also changed by other open PRs:

This may cause merge conflicts or duplicated work. A maintainer will coordinate.

@ascorbic
ascorbic merged commit af15975 into main May 7, 2026
52 of 53 checks passed
@ascorbic
ascorbic deleted the fix/admin-i18n-leaks-v2 branch May 7, 2026 14:37
@emdashbot emdashbot Bot mentioned this pull request May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants