Skip to content

feat(i18n): take the language set from SahajCloud, not from supportedLanguages #167

Closed as not planned

Description

@Ardnived

feat(i18n): take the language set from SahajCloud, not from supportedLanguages

Summary

The widget's language set is a build-time constant — supportedLanguages in
src/config/i18n-options.ts, pinned by i18n-options.test.ts to whatever public/locales/
contains. SahajCloud has just made the same list operator-configurable on the Sahaj Atlas
configuration global (sydevs/SahajCloud#645), and its SEO endpoint already emits hreflang from
it. This repo needs to read it too, or the two disagree the first time somebody changes it.

The widget currently fetches no Payload global at all. Not sy-atlas-config, not
sy-atlas-translations — the generated types exist in src/types/payload/, but the only globals
match in src/ is globals.css. So this is the first runtime config read, and the boot-order
question below is the real work, not the fetch.

Why this side has to change

SahajCloud can now say "the atlas is offered in cs, de, fr, nl". It cannot know whether this repo
ships a UI bundle for each of those — that is a fact about public/locales/, which only this
build knows.

A language enabled in the CMS with no bundle here renders the English fallback while SahajCloud's
hreflang tells crawlers that language has a page. That is a promise we can't keep, and it is
invisible at runtime: nothing errors, the viewer just gets the wrong language.

What to build

  1. Fetch sy-atlas-config and read its languages field — an array of { code } rows, where
    code is a CMS locale. (It is an array rather than a hasMany select, and named languages
    rather than locales, for reasons documented on the field in SahajCloud; treat both as fixed.)
  2. Drive supportedLanguages from that, replacing the constant. The settings picker and
    i18next's supportedLngs should both come from it.
  3. Fail loudly when a bundle is missing. Add a CI check asserting public/locales/ ⊇ enabled.
    This replaces the current equality assertion in i18n-options.test.ts, which becomes wrong the
    moment the CMS owns the list — but the drift check itself is the valuable part and should not
    just be deleted. Fetching the live global in CI is one option; a committed snapshot refreshed by
    a script (like pnpm sync:atlas-contract) is another, and keeps the unit lane off the network.
  4. Decide the boot order. i18n initializes synchronously at module load today; the config fetch
    is async and needs the API key. Either defer init until it lands (a visible boot change on
    someone else's page) or initialize with the shipped bundles and narrow once the config arrives.
    Worth measuring rather than assuming — the widget mounts inside a host page and a delayed first
    paint is a cost the host pays.

Interim state, and it is worth stating explicitly

SahajCloud ships first. Between that and this ticket, the global governs hreflang but not the
widget's own picker
— so an operator disabling a language removes it from search-engine
alternates while the widget still offers it. That is the safe direction of the two (we stop
advertising something rather than start), but it is a real divergence and shouldn't be discovered.

Until then, the CMS default is the current ten, so nothing changes for an installation that hasn't
touched the setting.

Not in scope

  • Changing which languages are enabled. That's now an operator decision, not a code change.
  • The translations global (sy-atlas-translations). Locale bundles still come from
    public/locales/ over HTTP from this repo's own asset host; only the enabled set moves.

Related

Activity

  1. added a commit that references this issue on Aug 25, 2026
  2. added theissue type on Aug 28, 2026
  3. Ardnived commented on Sep 5, 2026

    @Ardnived
    ContributorAuthor

    Superseded by #198 and the tracker sydevs/SahajCloud#702. sy-atlas-config.languages is being replaced by availableLocales (sydevs/SahajCloud#705), gated on published translations, and the widget will read its strings from the CMS too — so the "shipped ⊇ enabled" check this asked for has nothing to check once nothing is shipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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