Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/25922-studio-i18n-namespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@object-ui/i18n': patch
---

feat(i18n): a lazy `studio` namespace for the Studio designer's strings; the `designer.*` and `perm.*` keys move into it

Clause-②: no
Metadata-protocol: none

- **New subpath `@object-ui/i18n/namespaces/studio`.** The Studio designer's two-locale string set becomes a namespace of this package, as the maintainer ruled on objectstack#25922 (6431032267, Q2 = A; kept by 6431234244). `en` is resident; `zh` is its own chunk, fetched the first time a Chinese lookup asks for it; every other language reads `en`. Exports: `studioString(key, lang)` (synchronous; answers from `en` while a catalogue is in flight), `loadStudioCatalogue(lang)`, `isStudioCatalogueLoaded(lang)`, `resolveStudioLanguage(lang)`, the `useStudioCatalogue(lang)` hook (re-renders its caller when a fetched catalogue lands), `STUDIO_NAMESPACE`, `STUDIO_FALLBACK_LANGUAGE`, `STUDIO_LANGUAGE_CODES` and the `StudioCatalogue` type. Additive: nothing existing changes.
- **First slice of the move.** Every key under `designer.*` and `perm.*` (the object/field designer and the permission designer) now lives in the namespace instead of `@object-ui/app-shell`'s private table. Studio reads the same text in `en` and `zh`; a Chinese viewer sees these labels in English for the moment the `zh` catalogue takes to load, and a non-Chinese viewer no longer downloads these keys' Chinese text with the console.
- **Not in the eager catalogue.** `locales/en.ts` gains no key, and the namespace is not one of the ten packs, so `all-locales-key-parity` does not read it; its own parity (every `en` key has a `zh` row with the same `{placeholders}`) is a test of this package.
12 changes: 12 additions & 0 deletions ui/apps/console/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,18 @@ export default defineConfig({
{ name: 'i18n-locale-ru', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]locales[\\/]ru\.ts$/, priority: 84 },
{ name: 'i18n-locale-ar', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]locales[\\/]ar\.ts$/, priority: 84 },
//
// The Studio designer's `studio` namespace (objectstack#25922): the
// same one-group-per-catalogue rule, for the same reason. Its `zh`
// catalogue is `import()`ed on demand by
// `packages/i18n/src/namespaces/studio/index.ts`; without a group of
// its own it would fall to `i18n-runtime` below, which is eager, and
// the laziness would be real in the source and absent in the bundle.
// `en` is the namespace's resident fallback and gets its own chunk so
// its bytes are named in `eager-closure.json` instead of hiding in
// the runtime's.
{ name: 'i18n-ns-studio-en', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]studio[\\/]en\.ts$/, priority: 84 },
{ name: 'i18n-ns-studio-zh', test: /[\\/]packages[\\/]i18n[\\/]src[\\/]namespaces[\\/]studio[\\/]zh\.ts$/, priority: 84 },
//
// ⛔ `i18n-runtime` takes `includeDependenciesRecursively: false`
// for the reason `data-adapter` below does (objectui#9345, read out
// there in full): it outranks `framework` (83 over 80), and since
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ import { I18nProvider } from '@object-ui/i18n';
import { t } from './i18n';
import { __setCelFormulaLoader } from './celAuthoring';
import { CelTestRunDialog } from './CelTestRunDialog';
// The designer's `designer.*` / `perm.*` rows live in `@object-ui/i18n`'s `studio`
// namespace, whose `zh` catalogue is fetched on demand (objectstack#25922).
// Resident before any case, so the zh rows below read synchronously.
import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio';
await loadStudioCatalogue('zh');

afterEach(() => {
cleanup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ vi.mock('./AssignedUsersSection', () => ({

import { PermissionMatrixEditPage } from './PermissionMatrixEditor';

// The designer's `designer.*` / `perm.*` rows live in `@object-ui/i18n`'s `studio`
// namespace, whose `zh` catalogue is fetched on demand (objectstack#25922).
// Resident before any case, so the zh rows below read synchronously.
import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio';
await loadStudioCatalogue('zh');

/* ── The door ────────────────────────────────────────────────────────────── */

interface Call {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ describe('References panel — error ≠ empty ≠ loading (#5110)', () => {
/**
* The designer table carries `en` and `zh` in one file and is deliberately
* out of reach of the pack gates (see `metadata-admin/i18n.ts`'s header and
* `packages/i18n/README.md`, "Scope — the `engine.*` carve-out"), so a new
* `packages/i18n/README.md`, "Scope — the Studio designer strings"), so a new
* key added to only one of the two tables fails nowhere. This is that file's
* parity check for the three keys this card adds.
*
Expand Down
Loading
Loading