-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add theme localization #1778
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
Add theme localization #1778
Conversation
|
It's great to see someone working on this. However, I think theme localization could probably be either a built feature or a third party plugin. I don't intend to add any more builtin extensions. The only reason search is a plugin is because it used to be a builtin feature which some people did not want to use. So we broke it out into a plugin, but included it by default to maintain backward compatibility while providing users a mechanism to disable it. l10n is very different. First of all, it has not yet been supported so we break nothing by not including it by default. However, I am concerned that if the templates contain translation strings (such as To be clear, this should only cover translations of the templates themselves, not translation of any page content. Translation of page content should only be provided by a third party plugin. |
|
Thanks for your feedback! I did pretty much the same but built-in. See last update. |
waylan
left a comment
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.
Overall this looks like a great start. Thank you.
In addition to the few things I note below, we need to flesh out the rest of the translation (po) files and the template files need updated (obviously). And of course, this all needs to be documented.
|
For reference purposes, this PR is addressing step 1 of this comment on #211. Also, so that we don't forget about it, it might make sense for |
|
Beside documentation and your point about |
I suppose that should be defined in the template. Then, for backward compatibility, the script should only redefine it if it is not defined in the template. |
|
I finally had an opportunity to take a closer look at this. Looks good. However, the work is not done yet. At a minimum we need to do the following work:
On the last point, it appears that the following pieces are required to maintaining translations:
|
|
@anlau Are you still working on this? |
|
Not at the moment. Feel free to use the code from this PR. |
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.
|
Closing this as it was completed in #2299. |
<edit>
Note from project maintainers:
There are multiple aspects to supporting multiple languages in MkDocs, each of which is linked to from #211, which is the primary issue and ties all of the various aspects together. However, it is best to discuss each aspect in its related issue.
This issue/PR addresses theme localization (l10n). The templates need to be updated to support translations of the next/previous navigation, page footer, etc. Volunteers are needed to complete the work as outlined below.
</edit>
Goal: be able to use translations from PyBabel to localize a theme when built.
Before moving forward, I would like some feedback. There's a bit more work to do (mostly add tests). Second commit will be removed/or bonified (note: .mo files need to be generated with
pybabel compile -d locales). I think translations could be done in a separate PR.Related with this comment.