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.
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
.