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
Support theme localization (rework of #1778). #2299
Conversation
This branch is an attempt to renew the efforts put by @anlau in mkdocs#1778 in providing builtin theme localization support. mkdocs and readthedocs themes will support the 'locale' parameter which will use localized messages.po files to translate the theme templates. Contributors will thus be free to propose new messages.po for their own language. This PR proposes the 'en' (default) and 'fr' locales which should be compiled using : `pybabel compile -d locales` from the theme directory before they can be used. This code has also been tested and is compliant with the `mkdocs-static-i18n` plugin. The two of them combined provide a fully featured way to internationalize/localize your documentation.
da5d052
to
e569d9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. Of course, except for resolving the merge conflict, it appears that we still need to address all of the items listed in this comment.
|
|
supported dependency listing
@waylan looking at babel compilation automation I see that there's both a Are they both used? should I work on adding babel compilation to both? Also, requirements/packaging.txt does not seem to be referenced anywhere, is that intended or should I also add babel in there? |
Friendly ping on my questions above @waylan ; I have the modifications ready but don't want to commit useless stuff. Your input is appreciated. Thanks! |
Hmm, I typed up a response the other day and now it's gone. Must be I never submitted?? Sorry about that. Let's try this again... We use the GitHub workflow defined at .github/workflows/deploy-release.yml to automate MkDocs releases. Each time a new tag is created, that workflow automatically builds a MkDocs Python package and uploads it to PyPI.
In both cases, all of the dependencies in Note that we didn't make use of |
For completeness, when doing a manual release I would issue the following commands after ensuring that the git working is tree up-to-date and creating the git tag:
|
You are making some good progress. I still need to do a thorough review, but a brief look through everything looks good. There are no glaring concerns. To recap, it looks like the following is completed:
It appears that the last point is only partially completed. We still need the following:
|
As for the rest of your points, I think this is addressed in the theme translation contributing guide so there's no blocker imho. I'll let you check this out and hope you like it @waylan |
- release notes - styling your docs theme options + section - contribution guide
920569b
to
74a99ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ultrabug great job moving this forward.
I'm wondering if we should hardcode theme.locale
as a setting in mkdocs.theme.Theme
like we do static_templates
. That way we can be sure it always exists and has a default. Or maybe it makes more sense to leave it to be defined by the theme. That way a theme which doesn't provide any translations (MO) files doesn't need to bother with it.
A few other concerns are addressed below.
Ok I'll make time to try out and document what's left of this tomorrow I promise.
I was prepared for it and furthermore I was not alone on that road thanks to you, oprypin and Martin ;) The end is near and I hope the community will appreciate our efforts 👍 EDIT:
Okay, we'll do that separately |
Ok I tried this out and I just pushed:
Now I'll work on documenting messages.mo packaging. Since theme developers are free to do whatever they want, I feel like we should explain both options to either commit & push the messages.mo file or not. |
I had some time and finished up the documentation. @ultrabug unless you had other concerns I think this is ready for a final review and merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just took a final read through the changes and only noted one minor issue as outlined below.
bb5b251 is a fix that we did not catch since we changed the POT files headers; this broke new catalog initialization
now works as expected |
Tried the whole workflow again here to add a new locale translation, everything looks easy and good 👍 I'm excited to get this in for the community! |
Great! I expect to revisit it tomorrow and, barring any new concerns, merge it then. |
OMG 🏅 !! Thanks a lot, I hope this work proves useful to lots of users 🎉 |
Amazing work! Good job everyone! ❤️ |
This check has only caused a lot of spurious failures. I never check it. In my view this approach is still a non-starter, and my comments had predicted the problems quite spot-on: mkdocs#2299 (comment)
This check has only caused a lot of spurious failures. I never check it. In my view this approach is still a non-starter, and my comments had predicted the problems quite spot-on: mkdocs#2299 (comment)
This branch is an attempt to renew the efforts put by @anlau
in #1778 in providing builtin theme localization support.
mkdocs and readthedocs themes will support the 'locale' parameter
which will use localized messages.po files to translate the theme
templates.
Contributors will thus be free to propose new messages.po for
their own language.
This PR proposes the 'en' (default) and 'fr' locales which should
be compiled using :
pybabel compile -d locales
from the themedirectory before they can be used.
This code has also been tested and is compliant with the
mkdocs-static-i18n
plugin. The two of them combined provide afully featured way to internationalize/localize your documentation.