Skip to content

[Bug]: Admin console copy is not translatable in a composed site; project adminUi.* translations are dropped #227

Closed

Description

@jimhoyd

Runtime revision and environment

b0bc92dca958514eb01d3c2d7685af5382b6f708, Node v26.8.2, macOS 26.6.2. Local workspace
(packages/admin resolving @jimhoyd/urlcode-ui to this checkout), no deployment. This is a
checkout-behaviour report; it makes no claim about a published package.

Minimal reproduction

In a composed site (urlcode init site --with ui,auth,admin), ui/copy/<locale>.json is the one place
a project translates copy, and the scaffolded ui/copy/ directory invites exactly that. Kit and auth ids
placed there reach the rendered page. Admin-owned ids (adminUi.*) do not: they silently fall back to
bundled English.

packages/admin/src/admin-ui.ts builds the console's copy source with

source = createAdminPresentation({ base: kit.presentation });

and createAdminPresentation (packages/admin/src/admin-copy.ts) routes every adminUi.* key to an
inner presentation it builds from options.catalogues:

const { base: given, ...rest } = options;
const entries = Object.entries(options.catalogues ?? {});
const own = createPresentation({ ...rest, defaults: adminCatalogue, catalogues: ... });

On that call site options is { base } alone, so entries is [] and own is built with no
translations at all. The project's catalogues are present on base and are never passed to own, so
has/text for an admin key answer from English regardless of what the project translated.

Save as packages/admin/test/repro.ts and run
node --conditions=development --disable-warning=ExperimentalWarning test/repro.ts:

import { createPresentation, kitCatalogue } from '@jimhoyd/urlcode-ui';
import { createAdminPresentation } from '../src/admin-copy.ts';
// What createUiExtension builds for a site whose ui/copy/fr.json translates a kit id and an admin id.
const base = createPresentation({ defaults: kitCatalogue, catalogues: { fr: { 'ui.alert.error': 'Erreur', 'adminUi.noSessions': 'Aucune session active.' } } });
console.log('kit id  via base :', base.resolve({ queryLocale: 'fr' }).text('ui.alert.error'));
// What admin-ui.ts `presentationSource` builds from that kit presentation.
const admin = createAdminPresentation({ base });
const fr = admin.resolve({ queryLocale: 'fr' });
console.log('kit id  via admin:', fr.text('ui.alert.error'));
console.log('admin id via admin:', fr.text('adminUi.noSessions'));
console.log('fr coverage missing adminUi.noSessions?', admin.coverage('fr').missing.includes('adminUi.noSessions'));

Expected: adminUi.noSessions resolves to Aucune session active., as the kit id beside it does, and
the coverage report stops listing a key the project has translated.

Actual: the admin id renders in English, and coverage still reports it missing. A French console shows
translated chrome around untranslatable console text, and the coverage report asks the translator for a key
that has no effect once supplied.

Relevant output

kit id  via base : Erreur
kit id  via admin: Erreur
admin id via admin: No active sessions match these filters.
fr coverage missing adminUi.noSessions? true

Notes

  • packages/admin/test/admin-ux.test.ts:36 passes catalogues directly to createAdminPresentation, so
    the factory's own path is covered and passes; the { base } path the composed runtime actually takes is
    the one that drops them. A regression test for this belongs on the composed path.
  • Found while making urlcode-ui load peer namespaces. That work deliberately ships no catalogue on
    adminUiTemplates, so urlcode-ui copy --missing does not offer adminUi.* ids — offering ids the
    runtime then ignores would be worse than omitting them. If this is fixed, that decision should be
    revisited so the console's copy becomes translatable end to end and the tooling says so.
  • Related: [Request]: Wire UI customization into composed auth/admin scaffolds and document the AI authoring path #217 asks for a generated-consumer regression demonstrating a local template/copy override
    reaching an auth and admin screen. This is the concrete defect such a regression would catch on the
    admin side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions