Skip to content

feat(docs): Spanish routes for the guides, and header fixes - #24

Merged
crstian19 merged 4 commits into
mainfrom
fix/docs-header
Aug 12, 2026
Merged

feat(docs): Spanish routes for the guides, and header fixes#24
crstian19 merged 4 commits into
mainfrom
fix/docs-header

Conversation

@crstian19

Copy link
Copy Markdown
Contributor

Two things reported on the deployed docs header, and the second turned out to
need real work.

The wordmark went to the docs index

Clicking the logo took you to /docs rather than to the site. It is the brand
mark, and "Guides" right beside it already covers the docs index, so it now
goes to nan.builders.

The language switcher was missing from the guides

It only appeared on /docs/api, because that was the only page with a Spanish
version: /es/docs and /es/docs/models answered 404. helmcode shows the
switcher everywhere because it keeps every guide in both languages.

So the guides get Spanish routes. The Spanish copies ship as copies of the
English ones
, marked translated: false, and the page says so rather than
passing English off as a translation:

Esta página todavía no está traducida, así que se muestra en inglés.

Flipping that flag as each guide is really translated is the remaining job, and
it is content work rather than code.

Where the Spanish files live is not cosmetic

The obvious layout, docs/en/… and docs/es/…, would turn every entry id into
en/intro. SAFE_SLUG in src/lib/docsApi.ts rejects slashes and the
manifest route throws on the first one, so /api/docs/manifest.json would
answer 500 and the Discord bot would lose its entire knowledge base.

English therefore stays exactly where it is and Spanish goes in its own
collection, so the published slugs never move. There is a test pinning that.

The manifest is untouched and keeps serving English only. Whether the bot
should index Spanish as well is a separate decision with its own slug design.

Also in here

  • The breadcrumb is built from the locale-stripped path. Counting /es as a
    segment made every Spanish page show an extra crumb for the docs index.
  • Chrome strings, TOC label, search placeholder and prev/next are translated.
  • Every guide is listed in the sitemap in both languages with alternates.

Testing

662 tests green. Checked in a browser across both languages: the switcher
round-trips, the notice shows only where the flag says so, breadcrumbs read
correctly and the layout holds at 720px with no overflow.

Verified by mutation: reverting the breadcrumb fix, removing a Spanish guide,
or letting the two collections disagree on order each make the suite fail.

…itcher

The switcher only appeared on /docs/api because it was the only page with a
Spanish version: /es/docs and /es/docs/models answered 404. helmcode can show
it everywhere because it keeps every guide in both languages. Now so can we.

The Spanish guides ship as COPIES of the English ones, marked
`translated: false`, and the page says so instead of passing English off as a
translation. Flipping that flag as each guide is really translated is the whole
remaining job, and it is content work, not code.

Where the files live is not cosmetic. The obvious layout, `docs/en/…` and
`docs/es/…`, would turn every entry id into `en/intro`, and SAFE_SLUG in
src/lib/docsApi.ts rejects slashes: the manifest route throws on the first one,
so /api/docs/manifest.json would answer 500 and the Discord bot would lose its
entire knowledge base. English stays exactly where it is and Spanish goes in
its own collection, so the published slugs never move.

The manifest itself is untouched and keeps serving English only. Whether the
bot should index Spanish too is a separate decision with its own slug design.

Also in here:
- The wordmark in the header now goes to nan.builders instead of the docs
  index. It is the brand mark, and "Guides" right beside it already covers
  going to the docs index.
- The breadcrumb is built from the locale-stripped path: counting `/es` as a
  segment made every Spanish page show an extra crumb for the docs index.
- Chrome strings, TOC label, search placeholder and prev/next are translated.
- Every guide is now listed in the sitemap in both languages with alternates.

Verified in a browser across both languages: the switcher round-trips, the
notice shows only where the flag says so, breadcrumbs read correctly and the
layout holds. Tests verified by mutation: reverting the breadcrumb fix,
removing a Spanish guide or letting the two collections disagree on order each
make the suite fail.
… notice

The six guides are now real Spanish, not copies behind a warning, so the
notice and the `translated` flag it depended on are gone: schema field, layout
branch, style rule and route prop.

What was translated is the prose, the frontmatter and the copy inside the MDX
components (card descriptions, spec labels, capability lists). Left untouched:
code blocks, commands, model names, endpoint paths, terminal output, image
paths and the literal labels of the product UI, since those are what a reader
sees on screen and translating them would send people looking for a button
that does not exist.

Two things surfaced while checking it in a browser rather than in the diff:

- The API reference split the Spanish sidebar in two. Its nav group is not
  frontmatter, since it is not in either collection, so it was hardcoded to
  "Reference" and the Spanish nav came out with "Reference" and "Referencia"
  as separate sections. It now carries a label per locale.
- The rate limits block at the end of models.mdx was dropped in translation.
  Component counts between the two files now agree.

No em dashes anywhere in the Spanish text.

Tests updated to the new premises: the two collections must still agree on
`order`, must group their pages the same way whatever the labels say, must end
up with the same number of nav groups, and no Spanish page may be byte
identical to its English original. Verified by mutation, including that
reverting the group label to English fails the suite.
The card had its labels as literals inside the component, so it always
rendered one language regardless of the route. They were Spanish, leaked
into /docs, got translated to English, and then leaked into /es/docs the
other way round.

Move the labels next to the numbers they label, in rateLimits.ts, and
pick the locale from the route the page was rendered for, since MDX
content cannot receive props from the layout. The manifest that /api/docs
serves stays English: the locale defaults to 'en' and mdxToText does not
pass one.

Also fix a latent crash in the docs layout, where the default description
read `lang` before the destructuring had bound it. Any page without a
description would have thrown.

The guard only looked for Spanish inside English files, which is half the
problem, so it never saw this. The new tests check both directions and
fail if a literal comes back into the component.
The limits card said 3,000M next to a model card that says 3.000M on the
same page. Grouping is forced because es-ES leaves four-digit numbers
ungrouped, which would print 3000M instead.
@crstian19
crstian19 merged commit 165a205 into main Aug 12, 2026
1 check passed
@crstian19
crstian19 deleted the fix/docs-header branch August 12, 2026 12:22
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.

2 participants