Skip to content

Implement tab-based grouping for translations globals - #190

Merged
Ardnived merged 3 commits into
mainfrom
feature/translations-tab-grouping
Feb 3, 2026
Merged

Ardnived merged 3 commits into
mainfrom
feature/translations-tab-grouping

Conversation

@Ardnived

@Ardnived Ardnived commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Implement tab-based grouping for translations globals (Implement tab-based grouping for translations globals #189)
  • Create buildTranslationTabs() utility to convert nested JSON schemas into PayloadCMS tabs
  • Reorganize all translation schemas to use nested group structure
  • Update TranslationsTableField to fetch English values from field-specific paths

Changes

New Files

  • src/fields/translationsField.ts - Utility function to build tabs from nested schema
  • tests/int/translations-field.int.spec.ts - Unit tests (19 tests)
  • tests/int/translations-globals.int.spec.ts - Integration tests (18 tests)

Modified Files

  • Translation Schemas: Restructured to nested group format
    • WeMeditate Web: Common, Navigation tabs
    • WeMeditate App: Daily, Path, Explore, Profile, Meditation tabs
    • Sahaj Atlas: Common, Map, Location tabs
  • TranslationsTableField.tsx: Updated to fetch from englishData[fieldName] instead of englishData.strings
  • globals.md: Documentation for tab-based structure and key naming conventions

Key Naming Convention

  • Lowercase only with underscores (e.g., about_meditation)
  • No dots in keys - group structure handled by nested schema

Closes #189

Test Results

  • Unit tests: 19 passed
  • Integration tests: 18 passed
  • Build: ✓ Success

Note: 7 pre-existing test failures unrelated to this PR (cleanup-orphaned-media, storage-utils)

🤖 Generated with Claude Code

@Ardnived
Ardnived force-pushed the feature/translations-tab-grouping branch from 01e4265 to 3e6f9d3 Compare February 2, 2026 15:59
- Create buildTranslationTabs() utility function in src/fields/translationsField.ts
- Restructure all translation schemas to use nested group structure
- Update translations.ts files to use the new utility
- Update TranslationsTableField to fetch English values from field-specific path
- Key naming now uses lowercase with underscores (no dots)

Groups:
- WeMeditate Web: common, navigation
- WeMeditate App: daily, path, explore, profile, meditation
- Sahaj Atlas: common, map, location

Closes #189

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@Ardnived
Ardnived force-pushed the feature/translations-tab-grouping branch from 3e6f9d3 to 75ffdc5 Compare February 2, 2026 15:59
@Ardnived
Ardnived merged commit f176c45 into main Feb 3, 2026
@Ardnived
Ardnived deleted the feature/translations-tab-grouping branch February 3, 2026 04:08
Ardnived pushed a commit that referenced this pull request May 25, 2026
…S validate (Workers-safe) (#407)

Writes to wm-app-translations JSON fields fail on prod (Cloudflare
Workers) with:

  ValidationError: The following field is invalid: Navigation > Navigation
  → "Code generation from strings disallowed for this context"
    at beforeChange (worker.js)

Root cause: the JSON-field `jsonSchema` option compiles to an Ajv
validator (`new Ajv() + ajv.validate`) in payload's beforeChange field
validation. Ajv uses `new Function()` for performance, which Cloudflare
Workers' V8 isolate blocks with the CSP-style error above. The bug has
existed since the global was first introduced (#188 / #190) but was
latent because nothing ever wrote to these JSON fields on prod — the
admin UI showed empty fields and translators hadn't yet started. The
#393 seed import is the first thing to hit it.

Fix: drop `jsonSchema` from `createStringsJsonField` and reimplement the
same validation contract (required keys, additionalProperties,
per-key string-type checks) as a pure-JS `validate` function. No more
Ajv compilation, no more dynamic code generation. The admin UX is
unaffected because these JSON fields are rendered by the custom
TranslationsTable component (key/value rows), not Monaco, so the loss
of Monaco's schema hints costs nothing.

Generated types: `pnpm generate:types` produces a more generic shape
for the JSON fields (no inner-key types) since Payload was deriving
those from the jsonSchema. TranslationsTable + the seed converter both
work on the runtime data shape, not the generated TS types, so this is
purely a type-permissiveness regression with no runtime impact.

Wire-up: also adds 'wm-app-translations' to seeds/run.ts's local CLI
registry (ScriptName, VALID_SCRIPTS, SCRIPT_RUN_ORDER, SCRIPT_DESCRIPTIONS,
usage text). This was missed in #404 — the API route already knew about
the seed but the CLI rejected it as Unknown script. Note that the CLI's
cookie-forwarding auth is known-fragile against prod's Workers runtime
(per .claude session-handoff notes); the JWT-header path via direct
fetch to the API endpoint is the verified production-safe import path.

Tests:
- tests/int/translations-field.int.spec.ts — replace the 5 jsonSchema-
  assertion tests with 8 pure-JS validate tests covering: null/undefined
  passes, non-object rejection, missing-required-key rejection,
  unknown-key rejection (when additionalProperties is not true),
  unknown-key acceptance (when additionalProperties is true),
  non-string-value rejection for declared keys, well-formed object
  acceptance.
- tests/int/translations-globals.int.spec.ts — replace the 2 jsonSchema-
  assertion tests with assertions that jsonSchema is undefined and
  validate is a function on every JSON field of all three translation
  globals (wm-web-translations, wm-app-translations, sy-atlas-translations).
- All 728 integration tests + 26 unit tests pass; lint clean; typecheck
  clean for changed files. The 33 "errors" reported by vitest are
  pre-existing unhandled rejections from a payload package-version
  mismatch (@payloadcms/[email protected] vs [email protected]),
  not caused by this change.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement tab-based grouping for translations globals

1 participant