rust-unofficial / patterns

A catalogue of Rust design patterns, anti-patterns and idioms
https://rust-unofficial.github.io/patterns/
Mozilla Public License 2.0
7.84k stars 354 forks source link

Translations #345

Closed simonsan closed 1 year ago

simonsan commented 1 year ago

Comprehensive Rust has developed a nice translation mechanism for mdbook books: https://github.com/google/comprehensive-rust/blob/main/TRANSLATIONS.md

We could make some research on how to adapt to that workflow making it possible to translate Rust patterns to different languages.

Newer simplified Chinese could be the starter.

mgeisler commented 1 year ago

Hi @simonsan, I would love to see the infrastructure used elsewhere. We will eventually publish the i18n helpers (https://github.com/google/comprehensive-rust/issues/462), but for now I recommend installing them with

cargo install --git https://github.com/google/comprehensive-rust i18n-helpers
simonsan commented 1 year ago

Published now as https://github.com/google/mdbook-i18n-helpers 🚀

CC: https://github.com/rust-lang/mdBook/issues/5#issuecomment-1496364248

simonsan commented 1 year ago

It will probably still take some time until we can fully adopt it, as it seems like that Markdown formatting isn't transferred in the translation process. Afaiu that could destroy the ability to further translate things within a language, when we would reformat the original markdown.

Tracking: https://github.com/google/mdbook-i18n-helpers/issues/19

mgeisler commented 1 year ago

as it seems like that Markdown formatting isn't transferred in the translation process. Afaiu that could destroy the ability to further translate things within a language, when we would reformat the original markdown.

You are correct: the Markdown text is copied as-is to the PO files. So if you mass-format it, the translations will stop working.

My work arounds for this are:

I hope to write a tool for the second option soon since I plan to standardize the formatting of my own Markdown files.

simonsan commented 1 year ago

Thanks for the clarification <3

mgeisler commented 1 year ago

Maybe I should clarify that the mdbook-i18n-helpers extract the text on a per-paragraph basis right now. So changes only invalidate a single paragraph at a time.

If you add/remove a few words in a paragraph, Gettext will do a good job at finding the old paragraph when you update your xx.po file for the xx language. The entry is then marked "fuzzy", which is a signal to the translator that they need to update the old translation.