ReviewOS

also looking at this

stacks/stx

fix: translate fragment navigation titles

#2120
Merged chris wants to merge codex/farming-navigation-metadata into main
2 files +76 -0
packages/bun-plugin/src/serve.tsmodified+9-0
Changes to packages/bun-plugin/src/serve.ts
@@ -3748,6 +3748,15 @@ function __stxOverlay(errs){
37483748 html = ensureRouterConfig(html)
37493749
37503750 const headers = new Headers(res.headers)
3751 const fragmentTitle = headers.get('X-STX-Title')
3752 if (res.headers.get('X-STX-Fragment') === 'true' && fragmentTitle && i18nConfig && stx.applyTranslations) {
3753 // The fragment's title was captured before this final translation pass.
3754 // Treat it as HTML text while translating, then return plain title text
3755 // to the router. Escaping first preserves literal entities in the title.
3756 const titleHtml = escapeHtml(decodeURIComponent(fragmentTitle))
3757 const translated = stx.applyTranslations(titleHtml, i18nConfig, locale)
3758 headers.set('X-STX-Title', encodeURIComponent(decodeTitleEntities(translated)))
3759 }
37513760 headers.delete('content-length')
37523761 return new Response(html, {
37533762 status: res.status,