Skip to content

feat(core, theme-classic): allow overriding htmlLang#6371

Merged
slorber merged 1 commit into
facebook:mainfrom
noomorph:feat/override-html-lang
Jan 19, 2022
Merged

feat(core, theme-classic): allow overriding htmlLang#6371
slorber merged 1 commit into
facebook:mainfrom
noomorph:feat/override-html-lang

Conversation

@noomorph

@noomorph noomorph commented Jan 15, 2022

Copy link
Copy Markdown
Contributor

Motivation

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

    Besides, since it supports equally the Latin and Cyrillic scripts, you ought2 to specify the script as well: art-Latn-x-interslv and art-Cyrl-x-interslv respectively. 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 under art-Latn-x-interslv-etymolog.

  2. 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 your i18n section, 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

  1. See ConLang Code Registry: https://www.kreativekorp.com/clcr/

  2. See page 12: https://tools.ietf.org/search/bcp47

  3. http://steen.free.fr/interslavic/orthography.html#etymological_alphabet

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jan 15, 2022
@netlify

netlify Bot commented Jan 15, 2022

Copy link
Copy Markdown

✔️ [V2]
Built without sensitive environment variables

🔨 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

@github-actions

github-actions Bot commented Jan 15, 2022

Copy link
Copy Markdown

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 80
🟢 Accessibility 98
🟢 Best practices 93
🟢 SEO 100
🟢 PWA 92

Lighthouse ran on https://deploy-preview-6371--docusaurus-2.netlify.app/

@Josh-Cena Josh-Cena added pr: new feature This PR adds a new API or behavior. status: awaiting review This PR is ready for review, will be merged after maintainers' approval labels Jan 15, 2022
@slorber

slorber commented Jan 19, 2022

Copy link
Copy Markdown
Collaborator

Thanks, LGTM 👍

nice site, please add it to our showcase ;)

@slorber slorber merged commit 6f892e2 into facebook:main Jan 19, 2022
@Josh-Cena Josh-Cena removed the status: awaiting review This PR is ready for review, will be merged after maintainers' approval label Jan 19, 2022
@Josh-Cena

Copy link
Copy Markdown
Collaborator

Oops, forgot about docs🤦‍♂️

@slorber

slorber commented Jan 19, 2022

Copy link
Copy Markdown
Collaborator

😅 missed that too

@noomorph

Copy link
Copy Markdown
Contributor Author

@slorber , @Josh-Cena , so what action is required? Please elaborate and I'll try to supplement what's missing.

@Josh-Cena

Copy link
Copy Markdown
Collaborator

No worries @noomorph I'll write some docs. I have long planned to renew the i18n docs, going to document this change as well.

@slorber

slorber commented Jan 19, 2022

Copy link
Copy Markdown
Collaborator

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 ;)

slorber pushed a commit that referenced this pull request Jan 19, 2022
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
mrizwanashiq pushed a commit to mrizwanashiq/docusaurus that referenced this pull request Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants