Skip to content
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

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

Merged
merged 1 commit into from
Jan 19, 2022
Merged

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

merged 1 commit into from
Jan 19, 2022

Conversation

noomorph
Copy link
Contributor

@noomorph noomorph commented Jan 15, 2022

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
Copy link

netlify bot commented Jan 15, 2022

✔️ [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
Copy link

github-actions bot commented Jan 15, 2022

⚡️ 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
Copy link
Collaborator

slorber commented Jan 19, 2022

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
Collaborator

Oops, forgot about docs🤦‍♂️

@slorber
Copy link
Collaborator

slorber commented Jan 19, 2022

😅 missed that too

@noomorph
Copy link
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
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
Copy link
Collaborator

slorber commented Jan 19, 2022

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