Skip to content

feat(translations): CMS-sourced UI strings + availableLocales for Sahaj Atlas and WeMeditate Web (tracker) #702

Closed

Description

@Ardnived

Summary

Make SahajCloud the single source of truth for every UI string (English included) and for the set of locales each project offers, for Sahaj Atlas and WeMeditate Web. Consumers delete their local translations and read both from the CMS.

This is a cross-repo change with no atomic commit, so this issue exists to record the merge order. Producer: SahajCloud (three children). Consumers: SahajAtlasWeb and WeMeditateWeb (one child each), each blocked on the producer landing on main and production being seeded and published. WeMeditateApp is out of scope: its schema and globals are not edited; only the shared field builder changes (rendering, types, equivalent validation).

Background

  • wm-web-translations and sy-atlas-translations already exist, built by buildTranslationTabs() from a translationsSchema.json — but only the App consumes its global. The atlas widget ships 10 hand-maintained i18next bundles under public/locales/; WeMeditateWeb has no i18n layer (~150 hardcoded English literals, 41 screen-reader-only). Every one of wm-web-translations' 16 keys is unused by the site; sy-atlas-translations mirrors an old 2-namespace catalogue (23 dead keys, ~100 live keys missing).
  • Which locales a project offers is inconsistent: sy-atlas-config.languages (array of {code} rows, read only by the SEO hreflang builder, feat(api): serve SEO metadata for an atlas route (C3) — blocks the WordPress plugin and WeMeditateWeb SSR #645) vs three divergent hardcoded lists in WeMeditateWeb (19 CMS / 10 flag component / 5 dropdown).
  • Payload's locale fallback is per field, not per key: a partially translated locale returns its JSON blob minus the missing keys. Payload 3.86 ships experimental per-locale publish status (experimental.localizeStatus), which this adopts for the two web-project translations globals.
  • Production data: both web-project translations globals hold seed placeholders, except sy-atlas-translations.emails and event.title, which are live (registration emails, auto-titles) and keep their columns and values.

Decisions (clarified 2026-09-05)

  1. Close WeMeditateWeb#56, SahajAtlasWeb#28, SahajAtlasWeb#167 and PR SahajAtlasWeb#168 in favour of the children below; strike item 1 of refactor(fields): adopt jsonSchema for structured json fields #597 (it lands in child 1).
  2. Per-locale publish status via experimental.localizeStatus on sy-atlas-translations and wm-web-translations only. "Available" = _status[locale] === 'published'; completeness is not enforced.
  3. A reusable availableLocalesField({ translationsSlug }) (hasMany select over the CMS locales) on sy-atlas-config (replacing languages) and wm-web-config. Save is rejected if any selected locale's translations are not published. en is always required. Fallback for an unconfigured row is ['en']; ATLAS_DEFAULT_LOCALES is deleted and the old languages rows are not copied.
  4. Per-key English fallback happens in the CMS for API-client reads (afterRead hook, never for managers), so consumers do no client-side merge.
  5. Each consumer commits a generated English snapshot (pnpm sync:translations, never hand-edited) for first paint, tests, Ladle and the CMS-unreachable last resort. Runtime always prefers the CMS.
  6. Stay hardcoded in consumers: CMS-unreachable error copy, endonyms + brand wordmark + social platform names, editor/dev-only surfaces, CMS-block default copy.
  7. Translations JSON groups get a jsonSchema derived from the schema (typed groups in payload-types.ts, Ajv validation); a new strict: true extension makes maxLength block the save.
  8. Sub-groups render as collapsibles, not inner tabs; a page tab that has screen-reader-only strings declares explicit general + a11y sub-groups.
  9. Atlas call sites: one i18next namespace, nested keys (event.display.chip_full), %{x} interpolation, CMS plural: true families. WeMeditateWeb: a URL whose locale is not enabled returns 404; translations cached at the SETTINGS TTL (24 h).
  10. The localizeStatus migration ships drizzle-generated only: every locale of both translations globals reads Draft until an operator publishes (content columns untouched).

Merge order

SahajCloud (1) field infra ──► SahajCloud (2) atlas schema+seed ──► seed+publish prod ──► SahajAtlasWeb child
                            └─► SahajCloud (3) web schema+seed   ──► seed+publish prod ──► WeMeditateWeb child
  • Producer merges first, always. Each SahajCloud PR merges to main and deploys to Railway before the next starts: consumers pull src/payload-types.ts from main (pnpm types:cms), and a consumer pointed at an unmerged branch silently keeps the old shape.
  • After (2)/(3) deploy, an operator runs pnpm seed:prod translations, confirms each locale shows Published in the admin, then selects availableLocales on the config global. Only then do the consumer PRs open for review.
  • One PR per repo; no simultaneous merge.

Interim states (expected, not bugs)

  • After (1) deploys: every locale of both translations globals shows Draft until published; atlas hreflang shrinks to en; the widget (still on shipped bundles) keeps offering 10 — the safe direction. Registration emails and auto-titles are unaffected (main-row content reads).
  • After (2)/(3) deploy until the operator publishes and selects locales: same as above.
  • WeMeditateWeb changes nothing user-visible until its child ships.

Downstream

Merge in this order. Each child restates its blocking condition in its own body.

Producer — SahajCloud

Consumers — after their producer children are on main and production is seeded

Follow-ups (filed as stubs, not blocking)

Verification

  • Children (1), (2), (3) merged to main in that order; Railway deploys green; migrations applied on boot.
  • Production seeded; each atlas locale and web en show Published; availableLocales selected on both config globals.
  • GET /api/atlas/seo hreflang lists the selected atlas locales; GET /api/globals/sy-atlas-translations?locale=fr with a client key returns French with English merged into blanks.
  • Consumer children run pnpm types:cms only after their producer children are on main; both consumer PRs merged; no public/locales/** or hardcoded UI literal remains for a CMS-owned key.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    Priority

    Medium

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions