Summary: How website-next-js loads the full Nuxt locale message catalogue (the old lang/7mind/*.js files, about 450 KB across 9 locales) at build time in a Next.js Pages-Router app with output: 'export', keeps it out of the client bundle, and hands a small per-page slice to deeply nested components through React contexts. Sources: website-next-js port of the locale catalogue and the former in-checkout funnel (commits aa810ce, ce35279, a830d42, e82cc6f). Pairs with locale-aware-slugs-static-export. 2026-11-09: re-checked against website-next-js origin/main (lib/i18n/catalogue.ts, translate.ts, checkoutMessages.tsx, formBlokMessages.tsx, lib/coupon/couponMessages.tsx, components/storyblok/StoryblokRoute.tsx, components/checkout/CheckoutOverlay.tsx, docs/moved-to-public-pages.md, locales/de.js) Last updated: 2026-11-09


The problem

The Nuxt site served all per-locale copy from lang/7mind/*.js, now locales/*.js in the Next repo. The German catalogue alone is about 190 KB; all nine together are about 450 KB of object literals. In Nuxt, $t('couponPage.hero.heading') resolved these at runtime on the server. In a Next.js static export there is no server at request time, so the naive port (import the catalogue into a component and call t()) would bundle the entire 450 KB into the client JS for every page that touches a string. That is a non-starter.

The whole pattern below exists to load the catalogue at build time, serialize only the small slice a page needs into its prerendered HTML, and guarantee the rest never reaches a browser.


The pattern

1. Split pure helpers from the catalogue loader

Two modules, and the split is the whole point:

  • lib/i18n/translate.ts is catalogue-free. It exports createT(messages), the Messages / TranslateFn types, dot-path resolution (t('a.b.0.c')) and {var} interpolation. A client component may import it freely.
  • lib/i18n/catalogue.ts is build-time only. It statically imports all 9 locales/*.js and exports getCatalogue(locale), pick(catalogue, ...keys) and pickWithGermanFallback(locale, ...keys). Importing anything from here drags in all nine catalogues.

The rule that makes the boundary structural rather than tree-shaking-dependent: client components import createT from translate.ts, never from catalogue.ts. catalogue.ts is only ever imported by a page file’s getStaticProps.

2. Pick the slice in getStaticProps, pass via props

A page’s getStaticProps calls pick(getCatalogue(locale), 'couponPage', 'checkout') (or whichever top-level keys it renders) and returns the result as a messages prop. Next.js strips getStaticProps and everything it exclusively imports out of the client bundle. So getCatalogue and pick (and the 450 KB they pull) vanish from the browser; only the picked slice is serialized into that page’s __NEXT_DATA__. The component renders with createT(messages).

3. German fallback for missing slices

Coverage is uneven: couponPage exists in every locale except nl, and some slices (the B2B form copy, for example) were never translated. Vue i18n handled this with fallbackLocale: 'de'. There are two ways to do the same here:

  • At build time with pickWithGermanFallback(locale, ...keys): it picks the German slices and spreads the locale’s slices over them. Prefer this for new code; it keeps the German copy out of the client bundle. The Storyblok form bloks use it.
  • In the component with a small FALLBACK_DE object that the per-locale slice is spread over. Older pages (account, payments, /claim-gift, Charité, DAK, download, web-app) and the coupon provider still do this. Those German objects do ship to the client.

Both merges are shallow, so they only rescue absent top-level keys. A locale that carries a slice with a partial nested object loses the German sub-keys. In practice the major locales carry complete slices and nl omits whole top-level keys, so shallow is safe. If that stops being true, deep-merge.

Invented strings must live under a separate top-level namespace. The React port renders a few states the Vue catalogue has no key for. If you put them under the same top-level key as a real slice (for example couponPage.result), the per-locale merge replaces the whole couponPage object and silently drops them. Put them under a sibling key that pick() never returns (the _local namespace in checkoutMessages.tsx, applied after the merge) so the merge cannot touch them.

4. Deep component trees get a context, not prop-drilling

Bloks rendered deep inside the Storyblok pages get their copy from a context provider that the host page mounts with its picked slices. There are three:

  • CheckoutMessagesProvider / useCheckoutT() in lib/i18n/checkoutMessages.tsx: the checkout slice, used by the price cards (PriceMarketingSection). Mounted by StoryblokRoute, the /coupon and /claim-gift pages and the study page.
  • CouponMessagesProvider in lib/coupon/couponMessages.tsx: the slices CouponSection needs (couponPage, b2bPages, successPage, downloadPage).
  • FormBlokMessagesProvider in lib/i18n/formBlokMessages.tsx: the slices of the five Storyblok form bloks, loaded with pickWithGermanFallback.

Two properties keep them safe:

  • The context default is German copy. A blok rendered with no provider above it still shows the German it always did. (The form-blok provider only inlines the newsletter form chrome; its other keys show their key path when no provider is mounted.)
  • These modules import only translate.ts. They can ship to the client without dragging the catalogue in. The slice still comes from a page’s getStaticProps.

The checkout context was built for the in-checkout login and signup funnel (CheckoutAuth inside CheckoutOverlay). That funnel is gone: since 2026-09-14 CheckoutOverlay only redirects to app.<domain>/signup on frontend-public-pages, and CheckoutAuth, LoginForm, SignupForm and LoginPage are unreachable dead code (docs/moved-to-public-pages.md). Do not localize them.


The catch-all trap (read this before touching StoryblokRoute)

The shared Storyblok renderer components/storyblok/StoryblokRoute.tsx exports both the client component and a getStoryblokRouteProps() helper used by the page files’ getStaticProps. The getStaticProps stripping only applies to the actual getStaticProps export in a page file, not to a helper function living in a shared client module.

So you must NOT import catalogue.ts into StoryblokRoute.tsx (or any client module). Doing so leaks all nine catalogues into every landing page’s bundle. Instead, do the pick in each page file’s getStaticProps (pages/[locale]/index.tsx and pages/[locale]/[...slug].tsx), where stripping applies, and pass the result down as props (checkoutMessages and the form and coupon slices) that StoryblokRoute forwards into the providers.


How to verify nothing leaked

After yarn build, grep the client chunks in out/_next/static/ for a catalogue string that no page picks and that appears in no component fallback. Expect no hits. A reliable marker as of 2026-11-09 is “Alexa, starte 7Mind” from the alexaPage slice: it exists only in locales/de.js, and no page picks alexaPage. The markers this page used to name (“Krankenkassen übernehmen”, “Bewusster und entspannter”) are no longer in the catalogue, so a grep for them proves nothing. Before relying on a marker, confirm it is still in locales/de.js and in no file under components/ or lib/.

Because catalogue.ts imports all nine locales as one unit, the German catalogue’s absence proves the whole thing is absent. Do this check on the catch-all pages specifically (out/<locale>/index.html and a landing page), since they are the biggest surface and the easiest to leak from.

The small German fallback objects in page components and in the provider modules (a few KB) ship to the client on purpose. They are not the catalogue. Don’t mistake a hit on “Du bist bereits bei 7Mind angemeldet” (the checkout German default) for a leak.


What’s wired vs open (as of 2026-11-09)

  • Wired: account, payments, the Storyblok catch-all and home (checkout, coupon and form-blok slices), /coupon, /claim-gift, krankenkasse, study, download, Mondia, Charité, DAK, Barmer, the certificate page and the magazin and podcast index pages.
  • Gone: the gift purchase pages (retired 2026-09-24) and the in-checkout funnel. The login and reset-password slug pages still load their slices but only redirect to frontend-public-pages.
  • Open: nav and footer still use the hand-maintained lib/i18n/messages.ts and lib/i18n/footer.ts, not the catalogue.

See also