Skip to content
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 support for translations #49

Merged
merged 11 commits into from
Mar 5, 2023
Merged

Add support for translations #49

merged 11 commits into from
Mar 5, 2023

Conversation

avivace
Copy link
Sponsor Member

@avivace avivace commented Mar 2, 2023

Closes #25

Based on the i18n support implemented in https://github.com/google/comprehensive-rust

  • Credit https://github.com/google/comprehensive-rust for the translation system add headers+license in i18n related code
  • Add TRANSLATING file explaining how to contribute to translations and add new ones
  • Add a sample translation to start with (e.g. one page in Italian from Italian translation #32
  • Mention the translation guidelines in the README and in the book
  • Adapt the current build pipeline to go through the gettext preprocessor
  • Add a submenu linking to available translated versions of the book
  • Update CI to build translated versions of the book
  • If all of this is done, rebase it in two commits: one for adding the i18n code and the other for the italian po

@avivace avivace requested a review from ISSOtm March 2, 2023 21:48
Copy link
Member

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your help setting this up! I only have suggestions about some details; the overall process is very good!

.github/workflows/build-and-deploy.yml Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
book.toml Show resolved Hide resolved
po/it.po Outdated Show resolved Hide resolved
theme/index.hbs Show resolved Hide resolved
TRANSLATING.md Show resolved Hide resolved
Co-authored-by: Eldred Habert <eldredhabert0@gmail.com>
@avivace avivace requested a review from ISSOtm March 4, 2023 22:17
README.md Outdated Show resolved Hide resolved
TRANSLATING.md Show resolved Hide resolved
theme/index.hbs Show resolved Hide resolved
@avivace avivace requested a review from ISSOtm March 4, 2023 23:17
Copy link
Member

@ISSOtm ISSOtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's step 1 done :)

@ISSOtm ISSOtm merged commit 461df84 into master Mar 5, 2023
@mgeisler
Copy link

mgeisler commented Apr 5, 2023

Hi folks! Thanks for trying out the i18-helpers, I hope they're useful?

I just wanted to let you know that I've released them as a stand-alone crate now: https://crates.io/crates/mdbook-i18n-helpers. That should let you clean up the code here a bit 🙂

I noticed you use cargo run directly. With a downloaded crate, you should be able to replace that with cargo install --root tmp mdbook-i18n-helpers and then refer to tmp/bin/mdbook-xgettext and tmp/bin/mdbook-gettext in your book.toml.

Please open issues in the repository for any problems you run into. Thanks!

@avivace
Copy link
Sponsor Member Author

avivace commented Apr 8, 2023

Hi folks! Thanks for trying out the i18-helpers, I hope they're useful?

I just wanted to let you know that I've released them as a stand-alone crate now: crates.io/crates/mdbook-i18n-helpers. That should let you clean up the code here a bit slightly_smiling_face

I noticed you use cargo run directly. With a downloaded crate, you should be able to replace that with cargo install --root tmp mdbook-i18n-helpers and then refer to tmp/bin/mdbook-xgettext and tmp/bin/mdbook-gettext in your book.toml.

Please open issues in the repository for any problems you run into. Thanks!

Wow, thanks a lot @mgeisler ! I'll open another issue with the points you mentioned so we can take a look at this later. Thanks again for the amazing translation system, it's working very nice for us!

@mgeisler
Copy link

mgeisler commented Apr 9, 2023

Thanks again for the amazing translation system, it's working very nice for us!

Thanks for the feedback, I'm very happy it works for you!

@mgeisler
Copy link

Hey @avivace, I wanted to let you know about google/mdbook-i18n-helpers#46.

The current main branch of mdbook-i18n-helpers has a new text extraction system: it will turn # Some heading in the Markdown file into just "Some heading" in the PO file. Paragraphs are un-wrapped when extracted. Lists are now extracted on a per-item basis and tables are extracted on a cell-by-cell basis. This removes most of the Markdown syntax and makes the job easier for translators. It also allows you to freely reformat the Markdown files without invalidating the existing translations.

For this to work smoothly with existing translations, I've written a conversion tool: google/mdbook-i18n-helpers#46. When that is merged, I will make a new release. I hope you will be able to migrate to it as well.

Eventually, I want to release a GitHub action for all this: google/mdbook-i18n-helpers#48. That should make your life easier since you can export the complexity back to the mdbook-i18n-helpers repository 😄

@mgeisler
Copy link

I added a link to this projects in the mdbook-i18n-helpers README: google/mdbook-i18n-helpers#49. I hope you don't mind?

@avivace
Copy link
Sponsor Member Author

avivace commented Aug 14, 2023

I added a link to this projects in the mdbook-i18n-helpers README: google/mdbook-i18n-helpers#49. I hope you don't mind?

Sure, go ahead and thanks for the mention @mgeisler !

The current main branch of mdbook-i18n-helpers has a new text extraction system: it will turn # Some heading in the Markdown file into just "Some heading" in the PO file. Paragraphs are un-wrapped when extracted. Lists are now extracted on a per-item basis and tables are extracted on a cell-by-cell basis. This removes most of the Markdown syntax and makes the job easier for translators. It also allows you to freely reformat the Markdown files without invalidating the existing translations.

For this to work smoothly with existing translations, I've written a conversion tool: google/mdbook-i18n-helpers#46. When that is merged, I will make a new release. I hope you will be able to migrate to it as well.

This sounds very interesting and cleaning up the strings from formatting is definitely appreciated. Feel free to ping me when the migration tool is ready!

Eventually, I want to release a GitHub action for all this: google/mdbook-i18n-helpers#48. That should make your life easier since you can export the complexity back to the mdbook-i18n-helpers repository 😄

This is also interesting, maybe it can help automate our current workflow, which requires uploading the base po to crowdin..

@mgeisler
Copy link

This sounds very interesting and cleaning up the strings from formatting is definitely appreciated. Feel free to ping me when the migration tool is ready!

The converter tool is part of the new 0.2 release which I made last week.

I've created PRs for Comprehensive Rust today to update the translations. As an example, the Brazilian Portuguese page on scalar types is using the new system — the table you see there is translated cell-by-cell. If we change one of them in the English original, the others will remain translated.

@avivace avivace deleted the i18n branch November 27, 2023 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Translation
3 participants