timvink / mkdocs-print-site-plugin

MkDocs Plugin that adds an additional page that combines all pages, allowing easy exports to PDF and standalone HTML.
https://timvink.github.io/mkdocs-print-site-plugin/
MIT License
147 stars 23 forks source link

How to print i18n pages #70

Open roddc opened 2 years ago

roddc commented 2 years ago

I am using mkdocs-static-i18n to generate multi-language pages, but mkdocs-print-site-plugin only generates the default language for print-page.

Is there a option I can use to generate other languages?

timvink commented 2 years ago

Not yet. Haven't looked into this.

Something you'd like to pick up?

sarathorhalls commented 1 month ago

This would also be useful to me, and have interest in implementing it

timvink commented 1 month ago

What is the use case exactly?

You could just define an environment value to set the language, and create a loop in bash to build the docs in different languages?

sarathorhalls commented 1 month ago

I would rather not need to go that route and like the convenience that i18n gives me. Setting that up for the multiple projects I'm documenting. I'm more than willing to work on the feature as I really enjoy your implementation for non translated projects. If you could just point me in the general direction?

timvink commented 1 month ago

Ok cool.

So i18n adds links to translated pages to the top of every page.

The way this plugin works is that it 'collects' the pages. And it seems only the main language is picked up.

My approach would be to first inspect the docs/ folder, and see what the file structure is that i18n uses. Probably something with original filename and the language.

Then I would see if you can access the i18n plugin config in the final plugin event of print plugin. I've done this in the table-reader plugin before. Breakpoints are great for this, and you can explore the config yourself.

The idea would be to construct not 1, but multiple collections of files, and create multiple print pages (with the right language suffix). And then we add some links to the HTML print page

The last step would be to hide the i18n links when printing the HTML page (or exporting to PDF). You can do this using CSS, see the other elements where we do the same.

Not easy if this is your first mkdocs plugin contribution.. but feel free to dive in!