ultrabug / mkdocs-static-i18n

MkDocs i18n plugin using static translation markdown files
https://ultrabug.github.io/mkdocs-static-i18n/
MIT License
238 stars 38 forks source link

translating admonitions #293

Closed michalfapso closed 8 months ago

michalfapso commented 9 months ago

Thanks a lot for working on this project!

I have a documentation with multiple languages and I was looking for a way to translate admonitions.

I wasn't sure how should I add a test for it, whether to add an admonition into tests/docs_*_two_languages or should I create a separate testing doc?

ultrabug commented 9 months ago

Thanks for this amazing work @michalfapso

I'd rather you add tests to a separate tree so that it's strictly related to the feature and easier to cope with

Please rebase

michalfapso commented 9 months ago

Sure, now I've pushed a rebased commit with tests included.

ultrabug commented 9 months ago

@michalfapso I forgot to ask sorry but could you share a rationale of the problem you're trying to solve with an example as to why it's not possible currently?

michalfapso commented 9 months ago

Sure, @ultrabug, I have a documentation in English with quite a lot of admonitions. Then I have auto-translated it to several other languages which would be later manually corrected by a community. I'm using the material theme and your static-i18n plugin for it.

When I have !!! tip in my English documentation it gets rendered as "Tip" (as seen here: https://squidfunk.github.io/mkdocs-material/reference/admonitions/#supported-types). To translate it to another language I can write !!! tip "Conseil" which replaces the admonition title with "Conseil", but I would prefer to have a translation map for each admonition type so that its translated across the whole documentation consistently.

I could have written a separate script just to post process all markdown files and to add the translation of admonition titles directly to them, but I prefer not having those translations hard coded in all markdowns.

I already have some strings translated via nav_translations, so I find it convenient to have the proposed admonition_tranlstations right beside it in the mkdocs.yml.

Here are some related requests: https://github.com/squidfunk/mkdocs-material/discussions/4599 https://github.com/squidfunk/mkdocs-material/issues/749

ultrabug commented 9 months ago

Makes sense and I'm honored that the plugin could help people find a solution to a 2018 problem :+1: thanks

Please check my comments

michalfapso commented 9 months ago

Thanks for your comments, @ultrabug. I've tried to apply them in a new commit.

Do you prefer having separate commits of these subsequent changes or should I rebase and keep it in a single commit?

ultrabug commented 9 months ago

Do you prefer having separate commits of these subsequent changes or should I rebase and keep it in a single commit?

Rebase please, or I'll squash & merge np

ultrabug commented 9 months ago

Almost there!

ultrabug commented 8 months ago

All green, one final review and we should be good to go

ultrabug commented 8 months ago

Thanks and congratulations again @michalfapso

michalfapso commented 8 months ago

Thanks a lot, @ultrabug! It was my pleasure :)