Fix: correct <html lang> and localize the <head> description per locale#365
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<html lang>and the<head>description were stuck in the default language (English) regardless of the UI locale: the root(main)/layoutrenders<html>above the[locale]segment, so next-intl'sgetLocale()returns the default there. Both are strong "translate this page" triggers in Chrome.Changes
proxy.ts: expose the request pathname to server components asx-pathname, using the samex-middleware-request-*mechanism already used for the nonce.(main)/layout.tsx:resolveRequestLocale()derives the active locale fromx-pathname(falling back togetLocale()when the path has no locale segment); used for<html lang>and the localized description.meta_descriptionkey to all 17 locales. The English value is unchanged ("Minimalist webmail client using JMAP protocol").Type of Change
Checklist
npm run typecheck && npm run lintand there are no errorsnpm run build)locales/) if my changes affect user-facing text