feat(core, theme-classic): allow overriding htmlLang#6371
feat(core, theme-classic): allow overriding htmlLang#6371slorber merged 1 commit intofacebook:mainfrom noomorph:feat/override-html-lang
Conversation
|
✔️ [V2] 🔨 Explore the source changes: e5acb15 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61e2c33a3073150008a44ec6 😎 Browse the preview: https://deploy-preview-6371--docusaurus-2.netlify.app |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6371--docusaurus-2.netlify.app/ |
|
Thanks, LGTM 👍 nice site, please add it to our showcase ;) |
|
Oops, forgot about docs🤦♂️ |
|
😅 missed that too |
|
@slorber , @Josh-Cena , so what action is required? Please elaborate and I'll try to supplement what's missing. |
|
No worries @noomorph I'll write some docs. I have long planned to renew the i18n docs, going to document this change as well. |
|
It wouldn't harm to add it here quickly @noomorph : https://docusaurus.io/docs/api/docusaurus-config#i18n This way we are sure to not forget when updating the i18n doc ;) |
Motivation
I'm in the middle of building a website for Interslavic language which is available in multiple locales and scripts. The problem is that Interslavic language has quite a long BCP-47 language tag:
art-x-interslv.1Besides, since it supports equally the Latin and Cyrillic scripts, you ought2 to specify the script as well:
art-Latn-x-interslvandart-Cyrl-x-interslvrespectively. Also, the language has a for-internal-use script with extra etymological letters3, the so-called Etymological (or Scientific) alphabet, which we agreed to have underart-Latn-x-interslv-etymolog.Docusaurus is too coupled at the moment to the language code – you have to maintain directory and URL structure accordingly to the code. I'd like to shorten my directory names and URLs to
.../sla-Latn/...and.../sla-Cyrl/..., for example, but I'd still want to render the adopted BCP 47 language tag in the document markup.Without this feature, even the home page would have a URL like
https://interslavic.fun/art-Latn-x-interslv-etymolog, which looks clumsy.Have you read the Contributing Guidelines on pull requests?
Yes, although some parts I skimmed. 🙏
Test Plan
In your
docusaurus.config.js, try overriding youri18nsection, e.g.:i18n: { defaultLocale: 'en', + localeConfig: { + en: { htmlLang: 'en-GB' } + }After reloading the website, check that you see
<html lang="en-GB">in the rendered HTML markup.Related PRs
Footnotes
See ConLang Code Registry: https://www.kreativekorp.com/clcr/ ↩
See page 12: https://tools.ietf.org/search/bcp47 ↩
http://steen.free.fr/interslavic/orthography.html#etymological_alphabet ↩