Skip to content

feat(admin): add Lingui i18n infrastructure - #234

Merged
ascorbic merged 93 commits into
emdash-cms:mainfrom
ophirbucai:feat/admin-i18n-lingui
Apr 9, 2026
Merged

ascorbic merged 93 commits into
emdash-cms:mainfrom
ophirbucai:feat/admin-i18n-lingui

Conversation

@ophirbucai

@ophirbucai ophirbucai commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds Lingui i18n infrastructure to the admin UI — plumbing only, no bulk string wrapping. Zero user-visible change. String wrapping will follow in a separate PR once this merges.

What's included

  • Lingui setup: @lingui/core, @lingui/react, @lingui/macro with pnpm catalog
  • Locale system: resolveLocale() server-side, useLocale() client hook, cookie persistence
  • I18nProvider wired into the admin shell via PluginRegistry and App.tsx
  • Build pipeline: tsdown rolldown plugin compiles Lingui macros at build time — no Babel or Vite plugin in the published package
  • Pre-compiled catalogs: lingui compile produces .mjs at build time — consuming sites need zero Lingui config
  • Language selector UI in Settings (gated behind SUPPORTED_LOCALES.length > 1, invisible until a second locale ships)
  • Test harness: I18nProvider wrapper in test render utility
  • 3 proof-of-concept components wrapped (Settings, LoginPage, LocaleSwitcher) — 40 strings in catalog

What's NOT included (separate PRs)

  • Bulk string wrapping across ~60 admin components (feat/admin-i18n-strings)
  • Skill documentation for the locale workflow (feat/admin-i18n-skills)

Related

Design decisions

  • English only for now — language selector hidden until a second locale is added.
  • Role names left untouched — whether to translate Admin/Editor/Author/Contributor is a separate decision.
  • All @lingui/* versions managed via pnpm catalog.
  • Pre-compiled catalogs — lingui compile runs at admin build time. Consuming sites import .mjs, no Lingui config or Vite plugin needed.
  • Automatic macro compilation — tsdown rolldown plugin compiles Lingui macros at build time for the published npm package. No Babel or Lingui Vite plugin shipped in the core package. Consumers need zero Babel config.
  • No changeset included — no user-visible behavior change. Happy to add one if needed.

Review feedback addressed

  • Extracted inline locale:copy script to ./scripts/copy-locales.js
  • Renamed linguiBabelPlugin to linguiMacroPlugin for clarity (it's a rolldown plugin)
  • Removed Babel macro injection from the integration — no @babel/core or @lingui/vite-plugin in the published package

Type of change

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

Checklist

AI-generated code disclosure

  • This PR includes AI-generated code

Screenshots / test output

  • pnpm typecheck — passes
  • pnpm test — 48 test files, 713 tests pass
  • lingui extract — 40 strings in catalog (3 proof-of-concept components)
  • PR diff: 30 files, ~1,500 insertions (down from 289 files / +14,133)

@changeset-bot

changeset-bot Bot commented Apr 4, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1a037c5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@ophirbucai
ophirbucai force-pushed the feat/admin-i18n-lingui branch 3 times, most recently from b4b7a60 to ffa976f Compare April 4, 2026 12:00
@ophirbucai
ophirbucai marked this pull request as ready for review April 4, 2026 15:26
Copilot AI review requested due to automatic review settings April 4, 2026 15:26

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

Adds Lingui-based internationalization plumbing to the EmDash admin UI, including server-side locale resolution and client-side catalog activation, while wrapping existing admin strings with Lingui macros for future translation support.

Changes:

  • Introduces Lingui configuration, dependencies, and an admin locale API (resolveLocale, useLocale, supported locales config).
  • Wires Lingui into the admin shell (Astro route → plugin registry wrapper → AdminApp with I18nProvider).
  • Wraps/admin UI strings across routes and components using t, <Trans>, and <Plural> macros.

Reviewed changes

Copilot reviewed 82 out of 84 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
skills/adding-admin-locale/SKILL.md Adds internal documentation for adding locales and using Lingui macros.
pnpm-workspace.yaml Adds Lingui packages to the pnpm catalog.
packages/core/src/astro/routes/PluginRegistry.tsx Passes locale/messages props through to AdminApp.
packages/core/src/astro/routes/admin.astro Resolves locale server-side and imports the locale catalog for the admin shell.
packages/admin/tsdown.config.ts Expands build entrypoints to include locales index.
packages/admin/tsconfig.json Adds vite/client types for import.meta.env typing.
packages/admin/src/routes/users.tsx Wraps user management route strings with Lingui macros.
packages/admin/src/routes/bylines.tsx Wraps bylines route strings and labels with Lingui macros.
packages/admin/src/locales/useLocale.ts Adds a hook for client-side locale switching + cookie persistence + dynamic catalog import.
packages/admin/src/locales/index.ts Adds locale-related barrel exports.
packages/admin/src/locales/config.ts Defines supported locales and server-side locale resolution from cookie/Accept-Language.
packages/admin/src/index.ts Re-exports locale APIs from the package root.
packages/admin/src/components/WelcomeModal.tsx Wraps welcome modal strings and role labels with Lingui macros.
packages/admin/src/components/users/UserList.tsx Wraps user list UI strings with Lingui macros.
packages/admin/src/components/users/UserDetail.tsx Wraps user detail panel strings with Lingui macros.
packages/admin/src/components/users/InviteUserModal.tsx Wraps invite modal strings with Lingui macros.
packages/admin/src/components/ThemeToggle.tsx Wraps theme toggle labels/tooltips with Lingui macros.
packages/admin/src/components/ThemeMarketplaceDetail.tsx Wraps theme marketplace detail strings with Lingui macros.
packages/admin/src/components/ThemeMarketplaceBrowse.tsx Wraps theme marketplace browse strings with Lingui macros.
packages/admin/src/components/TaxonomySidebar.tsx Wraps taxonomy sidebar strings and aria-labels with Lingui macros.
packages/admin/src/components/Sidebar.tsx Wraps sidebar navigation group/item labels with Lingui macros.
packages/admin/src/components/SetupWizard.tsx Wraps setup wizard strings and introduces pluralization with Lingui macros.
packages/admin/src/components/settings/SocialSettings.tsx Wraps social settings strings with Lingui macros.
packages/admin/src/components/settings/SeoSettings.tsx Wraps SEO settings strings with Lingui macros.
packages/admin/src/components/settings/SecuritySettings.tsx Wraps security settings strings with Lingui macros.
packages/admin/src/components/settings/PasskeyItem.tsx Wraps passkey item strings with Lingui macros.
packages/admin/src/components/settings/GeneralSettings.tsx Wraps general settings strings with Lingui macros.
packages/admin/src/components/settings/EmailSettings.tsx Wraps email settings strings with Lingui macros.
packages/admin/src/components/settings/ApiTokenSettings.tsx Wraps API token settings strings with Lingui macros.
packages/admin/src/components/Settings.tsx Adds admin-language selector UI (gated) and wraps strings with Lingui macros.
packages/admin/src/components/SeoPanel.tsx Wraps SEO panel labels/descriptions with Lingui macros.
packages/admin/src/components/Sections.tsx Wraps sections UI strings with Lingui macros.
packages/admin/src/components/SectionPickerModal.tsx Wraps section picker modal strings with Lingui macros.
packages/admin/src/components/SectionEditor.tsx Wraps section editor strings with Lingui macros.
packages/admin/src/components/SaveButton.tsx Wraps save button labels with Lingui macros.
packages/admin/src/components/SandboxedPluginWidget.tsx Wraps sandboxed widget empty/error strings with Lingui macros.
packages/admin/src/components/SandboxedPluginPage.tsx Wraps sandboxed page error heading/message with Lingui macros.
packages/admin/src/components/RevisionHistory.tsx Wraps revision history UI strings (incl. conditional plural forms) with Lingui macros.
packages/admin/src/components/PluginFieldErrorBoundary.tsx Wraps plugin widget error fallback strings with Lingui macros.
packages/admin/src/components/MenuList.tsx Wraps menu list UI strings with Lingui macros.
packages/admin/src/components/MediaPickerModal.tsx Wraps media picker strings and pluralizes item count via Lingui macros.
packages/admin/src/components/MediaLibrary.tsx Wraps media library strings and introduces Lingui plural helpers for upload messaging.
packages/admin/src/components/MediaDetailPanel.tsx Wraps media detail panel labels/buttons with Lingui macros.
packages/admin/src/components/MarketplaceBrowse.tsx Wraps plugin marketplace browse strings and plural forms with Lingui macros.
packages/admin/src/components/LoginPage.tsx Wraps login strings with Lingui macros and adds (gated) locale selector.
packages/admin/src/components/LocaleSwitcher.tsx Wraps locale switcher labels/tooltips with Lingui macros.
packages/admin/src/components/Header.tsx Wraps header menu items with Lingui macros.
packages/admin/src/components/editor/PluginBlockNode.tsx Wraps editor plugin block node labels/tooltips with Lingui macros.
packages/admin/src/components/editor/ImageNode.tsx Wraps image node editor labels/tooltips with Lingui macros.
packages/admin/src/components/editor/DocumentOutline.tsx Wraps document outline strings with Lingui macros.
packages/admin/src/components/editor/BlockMenu.tsx Wraps block menu strings with Lingui macros and refactors transform labels.
packages/admin/src/components/DeviceAuthorizePage.tsx Wraps device authorization strings with Lingui macros.
packages/admin/src/components/Dashboard.tsx Wraps dashboard UI strings and count labels with Lingui macros.
packages/admin/src/components/ContentTypeList.tsx Wraps content type list strings with Lingui macros.
packages/admin/src/components/ContentPickerModal.tsx Wraps content picker modal strings with Lingui macros.
packages/admin/src/components/ConfirmDialog.tsx Wraps confirm dialog cancel label with Lingui macros.
packages/admin/src/components/comments/CommentDetail.tsx Wraps comment detail panel strings with Lingui macros.
packages/admin/src/components/BlockKitFieldWidget.tsx Wraps block-kit widget fallback/select labels with Lingui macros.
packages/admin/src/components/auth/PasskeyRegistration.tsx Wraps passkey registration strings with Lingui macros and adds default button text handling.
packages/admin/src/components/auth/PasskeyLogin.tsx Wraps passkey login strings with Lingui macros and adds default button text handling.
packages/admin/src/components/AdminCommandPalette.tsx Wraps command palette strings and navigation labels with Lingui macros.
packages/admin/src/App.tsx Adds I18nProvider and activates Lingui with server-provided locale/messages.
packages/admin/package.json Adds locale exports and Lingui scripts/dependencies.
lingui.config.ts Adds Lingui extraction configuration (English-only catalog).
demos/simple/package.json Adds Lingui tooling dependencies for the demo app.
demos/simple/astro.config.mjs Configures Babel macro plugin + Vite Lingui plugin in the demo Astro pipeline.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/admin/tsdown.config.ts:8

  • The published admin package won’t be able to load locale catalogs: useLocale() dynamically imports ./${code}/messages.po relative to the built dist/locales/* files, but the build config only emits JS/DTs and doesn’t copy .po catalogs into dist. This will make locale switching (and any runtime/SSR catalog import that targets dist) fail in consumer projects. Consider copying src/locales/**/messages.po into dist/locales/**/messages.po as part of the build (or changing the runtime import strategy) so the catalogs exist alongside the compiled locale modules.

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

Comment thread packages/admin/package.json Outdated
Comment on lines 20 to 23
"./locales/*": "./src/locales/*"
},
"scripts": {
"build": "tsdown && npx @tailwindcss/cli -i src/styles.css -o dist/styles.css --minify",

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

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

exports["./locales/*"] points at ./src/locales/*, but this package’s files list only publishes dist, so consumers won’t get src/locales/** (including messages.po). Additionally, the runtime locale loader in dist/locales/useLocale.js uses relative imports, so catalogs need to be present in dist anyway. Fix by either (a) publishing the .po catalogs (and any needed source) via files, or preferably (b) copying catalogs into dist/locales/** and exporting ./locales/* from dist.

Suggested change
"./locales/*": "./src/locales/*"
},
"scripts": {
"build": "tsdown && npx @tailwindcss/cli -i src/styles.css -o dist/styles.css --minify",
"./locales/*": "./dist/locales/*"
},
"scripts": {
"build": "tsdown && npx @tailwindcss/cli -i src/styles.css -o dist/styles.css --minify && node -e \"const fs=require('fs'); fs.mkdirSync('dist/locales', { recursive: true }); fs.cpSync('src/locales', 'dist/locales', { recursive: true });\"",

Copilot uses AI. Check for mistakes.
Comment thread demos/simple/package.json Resolved
Comment on lines +15 to +18
import { resolveLocale } from "@emdash-cms/admin/locales";

const resolvedLocale = resolveLocale(Astro.request);
const { messages } = await import(`@emdash-cms/admin/locales/${resolvedLocale}/messages.po`);

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

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

admin.astro now imports .po catalogs directly. That requires @lingui/vite-plugin to be present in the host app’s Vite pipeline for both dev and production builds; otherwise the .po import won’t be understood and the admin route build will fail. Since the EmDash integration’s Vite config currently only adds the virtual-modules plugin, consider either adding the Lingui Vite plugin at the integration level or switching to importing precompiled JS catalogs (so host apps don’t need extra Vite config).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ascorbic
The Lingui Vite plugin is currently configured in demos/simple only. For other demos, templates, and published sites, admin.astro's .po import will fail without it. We could inject it from the EmDash integration in astro:config:setup, but lingui() eagerly searches for a lingui.config.ts.

Which direction do you see this resolved? We can ship a default config from core, or resolve the catalog paths programmatically, unless you have other idea in mind?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there any downside to injecting it in the integration? That's generally the approach we'd take

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When someone installs emdash from npm and creates a site, they won't have a lingui.config.ts in their project. The integration would call lingui(), which calls getConfig(), which searches up from cwd and finds nothing.

In the monorepo (all demos, templates, CI), the root lingui.config.ts is always reachable. So it's only a problem for published consumers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will this then cause it to fail? I wonder if we can conditionally add the integration if the config exists, or add the config ourselves. We could at least add it to the default templates. Maybe it should be a config option for the integration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's looking good in part. However instead of auto-injecting the Vite plugin into the user's site, I'd pre-compile the .po files to JS. I think this could be done with he CLI as part of the admin build?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That makes absolute sense - I'll see that it works, all ping you once I am confident in the solution

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All done - consuming sites use the pre-built messages.mjs, which runs through lingui compile during build, no Lingui config or Vite plugin needed for consumers.
Dev mode imports .po via the Vite plugin so changes are reflected immediately during development.

@pkg-pr-new

pkg-pr-new Bot commented Apr 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

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

@emdash-cms/auth

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

@emdash-cms/blocks

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

@emdash-cms/cloudflare

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

emdash

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

create-emdash

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

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

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

@emdash-cms/x402

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

@emdash-cms/plugin-ai-moderation

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

@emdash-cms/plugin-atproto

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

@emdash-cms/plugin-audit-log

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

@emdash-cms/plugin-color

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

@emdash-cms/plugin-embeds

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

@emdash-cms/plugin-forms

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

@emdash-cms/plugin-webhook-notifier

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

commit: 1a037c5

@ophirbucai
ophirbucai force-pushed the feat/admin-i18n-lingui branch from 146b661 to 0c53403 Compare April 4, 2026 20:29
@ophirbucai

Copy link
Copy Markdown
Contributor Author

@ascorbic Hi Matt, the Lingui macros compile to useLingui() which requires I18nProvider in the React tree. To make component tests work, I've:

Created a shared test render utility (tests/utils/render.tsx) that wraps with I18nProvider
Updated 36 test files with a single import change:

- import { render } from "vitest-browser-react";
+ import { render } from "../utils/render.js";

No test logic changes — just the import path. The render utility initializes Lingui with empty English messages so source strings render as-is.

@ophirbucai

Copy link
Copy Markdown
Contributor Author

All 707 admin component tests passing locally, including the 36 test files updated to use the I18nProvider wrapper. Core tests (2,095) also pass.

@github-actions

github-actions Bot commented Apr 5, 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 commented Apr 5, 2026

Copy link
Copy Markdown
Member

This is looking great so far. I just need to get some clarity on how the setup will need to be handled for sites. Generally I want to avoid the need to install Vite plugins for core features

@ophirbucai
ophirbucai force-pushed the feat/admin-i18n-lingui branch from 827623e to bf8cf11 Compare April 8, 2026 22:04
@ophirbucai ophirbucai changed the title feat(admin): add i18n with Lingui feat(admin): add Lingui i18n infrastructure Apr 8, 2026
Comment thread packages/admin/package.json Resolved
Comment thread packages/admin/tsdown.config.ts Resolved
@ascorbic

ascorbic commented Apr 8, 2026

Copy link
Copy Markdown
Member

Good idea to separate the PRs. We're very close!

Restores admin source aliasing for instant HMR in monorepo dev mode.
Lingui macros are compiled via @babel/core dynamically imported from
admin's devDependencies — zero new deps in core's package.json,
nothing ships to end users.
@ophirbucai
ophirbucai requested a review from ascorbic April 9, 2026 10:43

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for all of your work on this!

@ascorbic
ascorbic merged commit 600068a into emdash-cms:main Apr 9, 2026
25 checks passed
@ophirbucai

Copy link
Copy Markdown
Contributor Author

Thanks for all of your work on this!

Sure! It was fun working on it.

ascorbic added a commit that referenced this pull request Apr 11, 2026
First community translation of the EmDash admin interface into German.
Uses formal 'Sie' form appropriate for DACH business context.
Covers all currently extracted admin strings (Settings, Login, LocaleSwitcher).

Follows the i18n infrastructure from PR #234.

Co-authored-by: Matt Kane <[email protected]>
fmhall pushed a commit to fmhall/emdash that referenced this pull request Apr 13, 2026
* docs: add admin UI i18n POC design spec

Design for a cookie-based locale switcher proving the full i18n loop
end-to-end: server reads cookie, loads locale JSON, passes to React
provider, components call t(), French strings appear.

* docs: add admin i18n POC implementation plan

8-task plan covering: i18n provider, locale JSON files, package exports,
admin.astro locale resolution, prop threading, Header locale selector,
proof-point string replacements, and E2E verification.

* feat(admin): add i18n types, provider, and useTranslation hook

* feat(admin): add English and French common translation files

* feat(admin): export i18n module and locale JSON files

* feat(core): add locale resolution to admin shell route

* feat: wire i18n provider through PluginRegistry and AdminApp

* feat(admin): add locale selector to header user dropdown

* feat(admin): replace hardcoded strings with t() in ConfirmDialog and SaveButton

* feat(admin): add locale selector to login page

* feat(admin): add language selector to settings hub

* refactor(admin): client-side locale switching without page reload

I18nProvider now manages locale state internally. Switching locale does
a dynamic import of the new JSON, updates React state, and sets the
cookie for the next server render. Removes duplicated setLocale/
SUPPORTED_LOCALES from Header, LoginPage, and Settings — all now use
useTranslation() from the provider. Locale selector removed from Header
dropdown (lives in LoginPage and Settings hub instead).

* feat(admin): add nav and settings translation namespaces

Translate Sidebar labels, Header dropdown items, and Settings hub page.
Nav namespace covers all navigation strings (sidebar, header, dropdown).
Settings namespace covers the settings hub card titles and descriptions.

* chore: format spec and plan docs

* refactor(admin): centralize i18n config and use import.meta.glob

Extract SUPPORTED_LOCALES, NAMESPACES, and DEFAULT_LOCALE into a shared
config.ts with Intl.Locale validation. Replace hardcoded per-locale
importer maps with import.meta.glob for automatic file discovery.
admin.astro now imports config from the admin package instead of
duplicating the locale list.

* docs: add adding-admin-locale skill

Reference guide for adding new locales and i18n namespaces to the admin
UI. Covers the full workflow: creating JSON files, registering in
config.ts, and translation key conventions.

* feat(admin): type-safe i18n translation keys

Derive translation key types from default locale JSON files via a barrel
export, so t() only accepts valid keys per namespace. Adds vite/client
types to admin tsconfig for import.meta.env support.

* docs: update adding-admin-locale skill for barrel-derived types

* refactor(admin): remove namespace prefix from translation keys

JSON files no longer repeat the namespace in every key — "common.save"
becomes just "save" in common.json. Keys are prefixed at load time via
prefixKeys(). Also extracts resolveLocale() from admin.astro into the
i18n module, and adds locale integrity tests to catch drift between
locales, namespaces, and the barrel export.

* feat(admin): migrate i18n from custom system to Lingui

Replace the custom i18n system (flat JSON files, useTranslation hook,
namespace-based key lookup) with Lingui. Components now use macros
(t`Save`, <Trans>) with source English as message IDs. Translation
catalogs use standard .po format at src/locales/{locale}/messages.po.

- Add @lingui/core, @lingui/react, @lingui/macro, @lingui/vite-plugin
- Convert all 6 components from useTranslation() to useLingui() macros
- Add useLocale() hook for client-side locale switching with validation
- Extract resolveLocale() for server-side locale resolution
- Populate French .po catalog (43/61 strings translated)
- Remove old I18nProvider, types, JSON files, barrel exports
- Wire Lingui Vite + Babel plugins into Astro pipeline

* docs: rewrite adding-admin-locale skill for Lingui

Completely replaces the old JSON/namespace-based instructions with
Lingui macro patterns, .po workflow, and extraction commands.

* chore: remove French locale files and simplify config

French translations are incomplete — remove .po files and config entry
until a fluent speaker can proofread. Keep only English as the default.

* chore(deps): remove an unused package and restore previously existing keys in simple package.json

* chore(admin): i18n infra — ci check, cleanup, review fixes

- Add i18n:extract and i18n:check scripts for CI catalog sync
- Fix App.tsx i18n initialization (remove useMemo misuse)
- Gate language selector on SUPPORTED_LOCALES.length > 1
- Remove @babel/plugin-proposal-decorators (unused)
- Restore peerDependencies/optionalDependencies in demo
- Remove obsolete spec/plan docs
- Remove stale comment in admin.astro
- Update adding-admin-locale skill with Trans guidance
- Sync en/messages.po catalog (1217 strings)

* feat(admin): wrap all admin components with Lingui macros

Convert 60 component files from hardcoded English strings to Lingui
t`` tagged templates and <Trans> macros. 1217 translatable strings
extracted. Zero user-visible change — English source text serves as
the message ID and default rendering.

* chore(admin): sync catalog after plural macro conversion

* refactor(admin): type BlockMenu transform labels with useMemo

* chore(admin): rename i18n scripts to locale:extract/locale:check

* fix(admin): don't translate email placeholder in InviteUserModal

* refactor(admin): remove role translation hook — role names are universal

* chore: format and fix skill JSX prettier issue

* style: move React import to top of PluginRegistry

* chore: add lingui packages to catalog, fix core type deps

Add @lingui/* packages to pnpm catalog for centralized version
management. Add @lingui/core as peer dep and @types/react as dev
dep to core package. Remove unused React import from PluginRegistry.

* revert: remove @lingui/core peer dep and @types/react from core

Leave these dependency decisions to the maintainer.

* feat(admin): wrap PluginBlockNode and PasskeyItem with Lingui macros

12 new translatable strings added for tooltips, aria-labels, and
the passkey removal confirmation dialog. 6 obsolete entries cleaned.

* fix(admin): use useLayoutEffect for i18n initialization

Wrap i18n.loadAndActivate in useLayoutEffect so it runs synchronously
before paint, avoiding a flash of untranslated strings. Includes
formatting cleanup in router.tsx and pnpm-workspace.yaml.

* fix(admin): harden BlockTransformId type with as const

BlockTransformId now resolves to a literal union instead of string,
providing actual type safety for the transform labels record.

* fix(admin): use Plural macro and extract nested t`` in i18n strings

SetupWizard: replace manual ternary plural with <Plural> macro for
proper plural form support across locales.
WordPressImport: extract nested t`` fallback to a variable for
cleaner .po catalog entries.

* revert(admin): restore inline nested t`` in WordPressImport

The nested t`` pattern is correct — inner t evaluates first as a
separate translatable string, then interpolates into the outer t.

* fix(admin): use catalog for demo lingui deps, restore untranslated roles

- Switch demos/simple @lingui/* deps to catalog: references
- Add @lingui/babel-plugin-lingui-macro and @lingui/conf to catalog
- Restore original getRoleLabel in WelcomeModal — role names untranslated

* fix(admin): match SetupWizard continue button to main branch

* fix(admin): add Lingui Babel plugin to vitest config for component tests

Admin component tests fail in CI because vitest can't resolve the
Lingui macro imports without the Babel plugin. Add
@lingui/babel-plugin-lingui-macro to admin devDeps and configure it
in vitest.config.ts.

* fix(admin): inline translatable data into useMemo for Lingui macros

Lingui's Babel macro only transforms t`` when t comes directly from
useLingui() in the same scope. Passing t as a function parameter to
helper functions (getSupportOptions, getFieldTypes, getDefaultSlashCommands)
produced empty strings at runtime. Inline the data into useMemo within
the component where t is in scope.

* fix(admin): restore three-dot ellipsis, escape ICU braces in i18n strings

SaveButton: use '...' (three dots) not '…' (unicode ellipsis) to match
upstream. ContentTypeEditor: escape {slug} as '{slug}' in t`` strings
so Lingui renders literal braces instead of treating them as ICU
placeholders.

* fix(admin): add I18nProvider test wrapper for Lingui component tests

Create shared render utility that wraps components with I18nProvider
so useLingui() works in all component tests. Composes with per-test
wrappers (QueryClientProvider, etc.) to avoid overriding. Initialize
i18n singleton in setup.ts. Add Babel macro plugin to vitest config.

* fix(admin): update test imports to use I18nProvider-wrapped render

Mechanical import change across 36 test files:
- import { render } from "vitest-browser-react"
+ import { render } from "../utils/render.js"

* chore(admin): sync .po catalog after useMemo migration and fixes

* docs: add lingui-macro-patterns skill with codebase conventions

Covers scope rules for t``, ICU escaping, useMemo+t vs msg pattern
decision, test wrapper composition, and common mistakes. Based on
lessons learned during the i18n implementation.

* fix(admin): use ref-based i18n init to avoid null render warning

Replace useLayoutEffect with a useRef guard that activates i18n
during the first render, before I18nProvider renders. Eliminates
the dev warning about I18nProvider rendering null.

* fix(e2e): add Lingui Vite and Babel plugins to e2e fixture

E2E tests failed because the fixture's Astro config didn't have the
Lingui Vite plugin for .po compilation or the Babel macro plugin for
t`` transforms.

* feat(admin): wrap aria-label attributes with Lingui t for accessibility i18n

33 aria-labels wrapped across 18 component files. 8 new translatable
strings added (Close, Admin navigation, Block actions, etc). Screen
readers will speak the user's locale when translations are available.

* fix(admin): inline command palette nav items into useNavItems hook

Extract buildNavItems helper into useNavItems hook + pure buildNavItems
function. t`` macros stay in the hook's useLingui() scope. Pure function
handles manifest collections, plugins, and role filtering. Preserves
original item ordering: Dashboard → collections → core links → plugins.

* fix(e2e): update upload test to match Lingui plural format

The upload success message changed from "File uploaded" to
"1 file uploaded" (Lingui plural). Use regex match to handle
both singular forms.

* style: format

* fix(admin): restore singular "File uploaded" message to match main

The Lingui plural rendered "1 file uploaded" instead of "File uploaded"
for single file uploads. Use "File uploaded" as the one-form to match
the original behavior.

* fix(e2e): restore exact upload test assertion to match main

Revert regex match back to exact 'text="File uploaded"' now that
the source renders the original singular form.

* feat(admin): pre-compile .po catalogs to JS, remove Vite plugin requirement

Compile .po → .mjs at admin build time via lingui compile --namespace es.
Import pre-compiled JS catalogs instead of raw .po files — no Lingui
Vite plugin needed in consuming sites.

- Add lingui compile to admin build script
- Switch admin.astro and useLocale.ts imports from .po to .mjs
- Remove @lingui/vite-plugin from demos/simple and e2e fixture configs
- Compiled messages.mjs committed as build artifact alongside .po source

* feat(admin): conditional .po/.mjs import based on dev/prod mode

Import .po in dev (Vite plugin compiles on the fly for instant
translation feedback) and pre-compiled .mjs in production (no plugin
needed). Conditional via import.meta.env.DEV.

* chore(demo): restore Lingui Vite plugin for dev mode .po compilation

Dev mode imports .po directly — the Vite plugin compiles on the fly.
Restore the plugin and its dependency in demos/simple.

* docs: update adding-admin-locale skill for dev/prod catalog workflow

Dev mode: edit .po, refresh browser — no compile or restart needed.
Production: lingui compile before committing generates .mjs.
Simplify steps and update common mistakes.

* fix(e2e): add Lingui Vite plugin for dev-mode .po imports

E2E runs astro dev where import.meta.env.DEV is true, importing .po
directly. Add the Vite plugin to compile .po on the fly.

Also remove messages.mjs from git tracking and gitignore it — it's a
build artifact generated by lingui compile, not a source file.

* refactor(admin): clean up test render wrapper with Fragment default

* fix: import pre-compiled .mjs catalogs everywhere, remove Vite plugin

Remove the import.meta.env.DEV conditional and Lingui Vite plugin
from all configs. All environments import .mjs (pre-compiled by
lingui compile during admin build). No Vite plugin needed anywhere.

* fix(e2e): remove leftover Lingui Vite plugin from e2e fixture

* fix(demos): add Babel macro plugin to all demos for Lingui support

Add @lingui/babel-plugin-lingui-macro to react() config in all demos
so Lingui t`` macros compile correctly during development.

* feat(core): inject Lingui Babel macro plugin in dev mode

Add a Vite plugin to the EmDash integration that compiles Lingui
macros (t``, <Trans>, <Plural>) when the admin is aliased to source
in dev mode. Uses enforce: "pre" to run before the React JSX
transform. No Babel config needed in consuming sites.

* docs(skill): update adding-admin-locale with macro compilation architecture

Reflects the new automatic macro compilation pipeline: tsdown plugin
for build, Vite plugin for dev. No consumer Babel config needed.

* style: format

* Update lockfile

* fix(core): externalize @babel/core from tsdown build

Prevents @babel/types from being bundled into dist — it's a dev-time
dependency used only by the emdash-lingui-macro Vite plugin.

* fix: remove orphaned @lingui/babel-plugin-lingui-macro from demos and e2e

These devDependencies were added when the Babel plugin was configured
in each consumer's astro.config. Now that the integration handles
macro compilation automatically, consumers don't need it.

* fix(core): use import.meta.glob for locale catalog loading

Variable dynamic imports fail for newly added locales because Vite
can't resolve the package-qualified path at analysis time. Glob
imports let Vite watch for new catalog files and serve them in dev
without a server restart.

* Revert "fix(core): use import.meta.glob for locale catalog loading"

This reverts commit a650af5.

* chore(skills): fix skill.md casing, add compile note for translations

Rename lingui-macro-patterns/skill.md to SKILL.md to match project
convention. Note in adding-admin-locale that lingui compile is needed
after editing .po files to see changes in dev.

* fix(skill): correct .mjs commit claim — files are gitignored

* fix(admin): copy locale catalogs to dist, fix export path and scripts

- Add locale:compile and locale:copy scripts
- Build now runs compile → tsdown → copy → tailwind
- Change ./locales/* export from src/ to dist/ for npm publish
- Remove locale:check (CI concern, not ours)
- Update SKILL.md to match new script names and correct stale claims

* fix(admin): wrap missed aria-label and placeholder strings with t macro

ContentList: View published aria-label
MenuList: Primary Navigation placeholder
MenuEditor: Home placeholder

* docs(skill): remove misleading commit instruction from locale workflow

* refactor: strip to infrastructure-only for PR split

* refactor: consolidate locale label lookup into config.ts

* refactor: extract locale:copy to ./scripts/copy-locales.js

* fix: rename linguiBabelPlugin to linguiMacroPlugin for clarity

* refactor: remove source aliasing and Babel from published core package

* style: format

* revert: restore integration files to upstream main state

* Revert "revert: restore integration files to upstream main state"

This reverts commit 33594c1.

* fix: subscribe to i18n change events in useLocale for reactive locale switching

* feat: dev-only source aliasing with dynamic babel macro transform

Restores admin source aliasing for instant HMR in monorepo dev mode.
Lingui macros are compiled via @babel/core dynamically imported from
admin's devDependencies — zero new deps in core's package.json,
nothing ships to end users.

* fix: restore uppercase locale codes in content locale switcher

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
Co-authored-by: Matt Kane <[email protected]>
Co-authored-by: Matt Kane <[email protected]>
fmhall pushed a commit to fmhall/emdash that referenced this pull request Apr 13, 2026
First community translation of the EmDash admin interface into German.
Uses formal 'Sie' form appropriate for DACH business context.
Covers all currently extracted admin strings (Settings, Login, LocaleSwitcher).

Follows the i18n infrastructure from PR emdash-cms#234.

Co-authored-by: Matt Kane <[email protected]>
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.

Platform UI internationalization — admin interface is English-only

3 participants