Skip to content

Fix: correct <html lang> and localize the <head> description per locale#365

Merged
rathlinus merged 1 commit into
bulwarkmail:mainfrom
dealerweb:pr/html-lang-active-locale
May 30, 2026
Merged

Fix: correct <html lang> and localize the <head> description per locale#365
rathlinus merged 1 commit into
bulwarkmail:mainfrom
dealerweb:pr/html-lang-active-locale

Conversation

@dealerweb
Copy link
Copy Markdown
Contributor

Summary

<html lang> and the <head> description were stuck in the default language (English) regardless of the UI locale: the root (main)/layout renders <html> above the [locale] segment, so next-intl's getLocale() returns the default there. Both are strong "translate this page" triggers in Chrome.

Changes

  • proxy.ts: expose the request pathname to server components as x-pathname, using the same x-middleware-request-* mechanism already used for the nonce.
  • (main)/layout.tsx: resolveRequestLocale() derives the active locale from x-pathname (falling back to getLocale() when the path has no locale segment); used for <html lang> and the localized description.
  • Add a meta_description key to all 17 locales. The English value is unchanged ("Minimalist webmail client using JMAP protocol").

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Checklist

  • I have read the Contributing Guide
  • My code follows the project's code style and conventions
  • I have run npm run typecheck && npm run lint and there are no errors
  • The build passes (npm run build)
  • I have tested my changes locally
  • I have updated translations (locales/) if my changes affect user-facing text

The root (main)/layout renders <html> ABOVE the [locale] segment, so next-intl's
getLocale() returns the default locale there - emitting <html lang="en"> on every
page regardless of UI language (e.g. /de) and a hardcoded English <head>
description. Both are strong "translate this page" triggers in Chrome.

proxy.ts already exposes the nonce to server components via the
x-middleware-request-* mechanism; expose the request pathname the same way as
x-pathname, and have the root layout derive the locale from it (falling back to
getLocale() when the path has no locale segment) for both <html lang> and the
localized meta_description (new key in all 17 locales; the English value is
unchanged).
@rathlinus rathlinus merged commit ad48f43 into bulwarkmail:main May 30, 2026
@dealerweb dealerweb deleted the pr/html-lang-active-locale branch May 31, 2026 14:11
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