✨ Generate automatic language names for docs translations#5354
✨ Generate automatic language names for docs translations#5354tiangolo merged 10 commits intofastapi:masterfrom
Conversation
The order of the content of the "Languages" and "alternate" sections in the mkdocs.yaml files have changed, which impacts the order the languages are shown on the UI in the language selector. Previously English was always shown first and the other languages were alphabetised by language code, now English is no longer a special case and appears in the middle of the list. The mapping of language code to local language name was sourced from https://quickref.me/iso-639-1. Where were discrepancies in capitalisation and/or in language name the existing names were reused.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5354 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 540 539 -1
Lines 13969 13906 -63
=========================================
- Hits 13969 13906 -63 ☔ View full report in Codecov by Sentry. |
|
📝 Docs preview for commit 08870c6 at: https://63173af067cd57620b0f776e--fastapi.netlify.app |
Thanks for the quick response! |
|
📝 Docs preview for commit c485045 at: https://63177291e5cb61009f26b0ae--fastapi.netlify.app |
|
Thanks for the review @BilalAlpaslan. I noticed that the link to go back to the English version was wrong, it was |
|
📝 Docs preview for commit 9a1e1d0 at: https://6318879624607c39852e219f--fastapi.netlify.app |
|
📝 Docs preview for commit a58f46b at: https://639cce20a7d043140d04044c--fastapi.netlify.app |
|
Honestly, if not for you, I would not have known about switching the language at the top of the page. 🤭 |
|
📝 Docs preview for commit 5b1d076 at: https://7e140f4b.fastapitiangolo.pages.dev |
|
Great idea, thank you @jakul! This looks great. 🚀 And thanks for the reviews @creyD, @BilalAlpaslan, @MrRawbin, @Xewus, @alejsdev 🍰 I updated |

This PR does two things:
Update the code that generates the mkdocs.yml files to always include a local language name
The local language name is read from a new file which contains mappings for all the allocated ISO 639-1 language codes, and the content of that file is sourced from https://quickref.me/iso-639-1, though with updates to persist the existing language names where there was a difference with the existing name for the language in the FastAPI source.
Regenerate all the mkdocs.yaml files