-
Notifications
You must be signed in to change notification settings - Fork 25.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page locale #4862
Page locale #4862
Conversation
The W3C [recommends](https://www.w3.org/International/questions/qa-html-language-declarations) to specify language using identifiers as per [RFC 5646](https://tools.ietf.org/html/rfc5646) which uses dashes.
Allows a page to override the site locale for this one page.
Nice job. Can this be changed so that when a page-level override isn't present, it won't emit the |
Hmm, I did not think about it that way. My thought was that we always know the language (at least the default system fallback would be available). But if it's a blocker to merging the PR I can certainly make that change. |
My take on this is that it's a per-page settings override, so the |
Makes sense. I'll update the PR. |
I pushed another commit that emits the lang attribute only if |
The W3C [recommends](https://www.w3.org/International/questions/qa-html-language-declarations) to specify language using identifiers as per [RFC 5646](https://tools.ietf.org/html/rfc5646) which uses dashes.
This is a feature.
Summary
This PR allows for a page to specify a content
locale
that is used only for that one page.Compared to the similar PR #4679, this set of changes is relatively small, as I am not going for localising anything. Instead, the focus is on expressing the actual locale of the content, as it is written in the page and declared as
locale
in the front matter, in the containing element'slang
attribute.Fallback to
site.locale
is present where applicable.This PR has an associated commit that writes the site locale (
lang
attribute of thehtml
element) in the style the W3C recommends (language and region separated by dash), instead of just cutting off the region. Let me know if you'd prefer this one as a separate PR.Context
I am running my blog mostly in English, but a few pages are in German. I am running a spell checker across all pages before publishing them, and having an accurate locale on each page is crucial for that.
Example
A site that has
locale: en_US
in its_config.yaml
generates the followinghtml
element:A page may specify that its content is written in German:
With this PR, the rendered HTML looks like this:
Everything is still being treated as written in the site's locale
en-US
, but this one page declares its main content correctly asde-DE
.