docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

feat(i18n): support translating through locale extensions `myDoc.fr.md`

Open slorber opened this issue 2 years ago â€ĸ 3 comments

Motivation

Translating through the i18n folder is nice for i18n SaaS integrations (Crowdin)

But it is not ideal for simpler needs based on Git, as it requires to explain the i18n folder structure convention.

To make i18n simpler to adopt, let's add support for localized file extensions to all our core content plugins

  • ./docs/myDoc.fr.md
  • ./blog/myBlog.fr.md
  • ./src/pages/myPage.fr.tsx

This kind of convention is already used by other documentation frameworks:

  • https://ultrabug.github.io/mkdocs-static-i18n/getting-started/quick-start/
  • https://nextra.site/docs/guide/i18n#add-locale-to-filenames

Note, we also want to support this for metadata files:

  • docs _category_.fr.yml
  • blog authors.fr.yml

Note, the editUrl and editLocalizedFiles options should rather work as expected too

Test Plan

Unit tests + dogfood

Test links

https://deploy-preview-9700--docusaurus-2.netlify.app/

Local:

  • http://localhost:3000/fr/tests/pages/i18n
  • http://localhost:3000/fr/tests/blog/i18n
  • http://localhost:3000/fr/tests/docs/i18n

slorber avatar Jan 04 '24 17:01 slorber

[V2]

Name Link
Latest commit e9b20ca990ccf00a6c38336781a4f68b2dfa1748
Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/65970249b391480008b5d1a4
Deploy Preview https://deploy-preview-9700--docusaurus-2.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Jan 04 '24 17:01 netlify[bot]

âšĄī¸ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 65 đŸŸĸ 98 đŸŸĸ 100 đŸŸĸ 100 🟠 89 Report
/docs/installation 🟠 69 đŸŸĸ 98 đŸŸĸ 100 đŸŸĸ 100 🟠 89 Report
/docs/category/getting-started 🟠 75 đŸŸĸ 100 đŸŸĸ 100 đŸŸĸ 90 🟠 89 Report
/blog 🟠 75 đŸŸĸ 100 đŸŸĸ 100 đŸŸĸ 90 🟠 89 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 65 đŸŸĸ 97 đŸŸĸ 100 đŸŸĸ 100 🟠 89 Report
/blog/tags/release 🟠 74 đŸŸĸ 100 đŸŸĸ 100 🟠 80 🟠 89 Report
/blog/tags 🟠 75 đŸŸĸ 100 đŸŸĸ 100 đŸŸĸ 90 🟠 89 Report

github-actions[bot] avatar Jan 04 '24 17:01 github-actions[bot]

Size Change: +1.84 kB (0%)

Total Size: 929 kB

Filename Size Change
website/.docusaurus/globalData.json 59.5 kB +317 B (+1%)
website/build/assets/js/main.********.js 718 kB +1.52 kB (0%)
â„šī¸ View Unchanged
Filename Size
website/build/assets/css/styles.********.css 114 kB
website/build/index.html 37.9 kB

compressed-size-action

github-actions[bot] avatar Jan 04 '24 17:01 github-actions[bot]