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

✨ Generate automatic language names for docs translations #5354

Merged
merged 10 commits into from Jan 9, 2024

Conversation

jakul
Copy link
Contributor

@jakul jakul commented Sep 6, 2022

This PR does two things:

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

    ⚠️ The old code always put English at the top of the language list in the UI, but the new code doesn't

    Before After
    Captura de Pantalla 2022-09-06 a las 13 05 30 Captura de Pantalla 2022-09-06 a las 13 03 10
  2. Regenerate all the mkdocs.yaml files

Craig Blaszczyk added 2 commits September 6, 2022 13:11
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
Copy link

codecov bot commented Sep 6, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cf73051) 100.00% compared to head (9a1e1d0) 100.00%.
Report is 951 commits behind head on master.

❗ Current head 9a1e1d0 differs from pull request most recent head f35dcc5. Consider uploading reports for the commit f35dcc5 to get more accurate results

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.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2022

📝 Docs preview for commit 08870c6 at: https://63173af067cd57620b0f776e--fastapi.netlify.app

scripts/docs.py Outdated Show resolved Hide resolved
Copy link
Contributor

@MrRawbin MrRawbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! Good job.

@jakul
Copy link
Contributor Author

jakul commented Sep 6, 2022

Very cool! Good job.

Thanks for the quick response!

@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2022

📝 Docs preview for commit c485045 at: https://63177291e5cb61009f26b0ae--fastapi.netlify.app

@jakul
Copy link
Contributor Author

jakul commented Sep 7, 2022

Thanks for the review @BilalAlpaslan.

I noticed that the link to go back to the English version was wrong, it was /en/ instead of /. I've fixed that in a new commit.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2022

📝 Docs preview for commit 9a1e1d0 at: https://6318879624607c39852e219f--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit a58f46b at: https://639cce20a7d043140d04044c--fastapi.netlify.app

@Xewus
Copy link
Contributor

Xewus commented Apr 19, 2023

Honestly, if not for you, I would not have known about switching the language at the top of the page. 🤭

@bharathkalyans
Copy link

Actually, I was about to raise a PR regarding this issue, but found your PR that hasn't been yet merged 🥲.
Also, we have a new emoji language and I think shifting it below would give a better experience. Your take on this?
Screenshot 2023-08-27 at 9 58 53 PM

Copy link

@creyD creyD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR, looks good.

@alejsdev alejsdev changed the title Feat/5060 Automatic language names ✨ Generate automatic language names for docs translations Jan 9, 2024
@alejsdev alejsdev added the docs Documentation about how to use FastAPI label Jan 9, 2024
@tiangolo
Copy link
Owner

tiangolo commented Jan 9, 2024

📝 Docs preview for commit 5b1d076 at: https://7e140f4b.fastapitiangolo.pages.dev

@tiangolo
Copy link
Owner

tiangolo commented Jan 9, 2024

Great idea, thank you @jakul! This looks great. 🚀

And thanks for the reviews @creyD, @BilalAlpaslan, @MrRawbin, @Xewus, @alejsdev 🍰


I updated docs.py with the recent changes and language setup refactor to use this data, and I updated the file to be YAML instead of JSON, just because all the other config files are YAML too, so, just for consistency. 😅

@tiangolo tiangolo enabled auto-merge (squash) January 9, 2024 20:33
@tiangolo tiangolo merged commit 7eeacc9 into tiangolo:master Jan 9, 2024
36 checks passed
@jakul jakul deleted the feat/5060-automatic-language-names branch January 10, 2024 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation about how to use FastAPI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants