Repository navigation
feat(admin): add Lingui i18n infrastructure - #234
Conversation
|
b4b7a60 to
ffa976f
Compare
There was a problem hiding this comment.
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 →
AdminAppwithI18nProvider). - 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.porelative to the builtdist/locales/*files, but the build config only emits JS/DTs and doesn’t copy.pocatalogs intodist. This will make locale switching (and any runtime/SSR catalog import that targetsdist) fail in consumer projects. Consider copyingsrc/locales/**/messages.pointodist/locales/**/messages.poas 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.
| "./locales/*": "./src/locales/*" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsdown && npx @tailwindcss/cli -i src/styles.css -o dist/styles.css --minify", |
There was a problem hiding this comment.
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.
| "./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 });\"", |
| import { resolveLocale } from "@emdash-cms/admin/locales"; | ||
|
|
||
| const resolvedLocale = resolveLocale(Astro.request); | ||
| const { messages } = await import(`@emdash-cms/admin/locales/${resolvedLocale}/messages.po`); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
Is there any downside to injecting it in the integration? That's generally the approach we'd take
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Here's a working implementation: https://github.com/ophirbucai/emdash/compare/feat/admin-i18n-lingui...spike/lingui-integration-injection
The lingui.config.ts is distributed through the core build - tsdown.config.ts
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
That makes absolute sense - I'll see that it works, all ping you once I am confident in the solution
There was a problem hiding this comment.
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.
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
146b661 to
0c53403
Compare
|
@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 - 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. |
|
All 707 admin component tests passing locally, including the 36 test files updated to use the I18nProvider wrapper. Core tests (2,095) also pass. |
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
|
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 |
827623e to
bf8cf11
Compare
|
Good idea to separate the PRs. We're very close! |
This reverts commit 33594c1.
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.
ascorbic
left a comment
There was a problem hiding this comment.
Thanks for all of your work on this!
Sure! It was fun working on it. |
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]>
* 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]>
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]>
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/core,@lingui/react,@lingui/macrowith pnpm catalogresolveLocale()server-side,useLocale()client hook, cookie persistencePluginRegistryandApp.tsxlingui compileproduces.mjsat build time — consuming sites need zero Lingui configSUPPORTED_LOCALES.length > 1, invisible until a second locale ships)I18nProviderwrapper in test render utilityWhat's NOT included (separate PRs)
feat/admin-i18n-strings)feat/admin-i18n-skills)Related
Design decisions
@lingui/*versions managed via pnpm catalog.lingui compileruns at admin build time. Consuming sites import.mjs, no Lingui config or Vite plugin needed.Review feedback addressed
locale:copyscript to./scripts/copy-locales.jslinguiBabelPlugintolinguiMacroPluginfor clarity (it's a rolldown plugin)@babel/coreor@lingui/vite-pluginin the published packageType of change
Checklist
pnpm typecheckpassespnpm --silent lint:json | jq '.diagnostics | length'returns 0pnpm testpasses (713 tests)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
pnpm typecheck— passespnpm test— 48 test files, 713 tests passlingui extract— 40 strings in catalog (3 proof-of-concept components)