also looking at this
fix: translate fragment navigation titles
#2120
2 files
+76
-0
| @@ -3748,6 +3748,15 @@ function __stxOverlay(errs){ | ||
| 3748 | 3748 | html = ensureRouterConfig(html) |
| 3749 | 3749 | |
| 3750 | 3750 | 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 | } | |
| 3751 | 3760 | headers.delete('content-length') |
| 3752 | 3761 | return new Response(html, { |
| 3753 | 3762 | status: res.status, |