-
Notifications
You must be signed in to change notification settings - Fork 310
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 i18n support #722
Add i18n support #722
Conversation
Hi! Thanks for opening this pull request! 😄 |
Done
Hmm good question. Is it possible that, you firstly configure everything under your fork? |
@all-contributors please add @trdthg for doc |
I've put up a pull request to add @trdthg! 🎉 |
Yes, It's not really that complicated, except that you have to clone two other copies of the mdBook. # [Add commands for Gettext-based translations i18n #1864](https://github.com/rust-lang/mdBook/pull/1864)
# extract and generate pot/po file
MDBOOK1="path to #1864 mdbook"
# [Add option to localize books in multiple languages #1306](https://github.com/rust-lang/mdBook/pull/1306)
# add multi-language support
MDBOOK2="path to #1306 mdbook" |
Great! Btw is the translatetool written by you? Maybe we can merge it into |
Yes.
Good idea. You may do some more detailed check. |
93ca448
to
5b71805
Compare
dcada79
to
235567a
Compare
Here is the current progress. I moved scripts to But I don't really like this solution, and I found rust-lang/mdBook#5 (comment) today, which seems to be better. Should I switch? |
Depend on you. When doing https://github.com/fzyzcjy/flutter_smooth, I tried http://cjycode.com/flutter_smooth/, which uses https://docusaurus.io/. That one seems to have excellent multi-lang support. So you can even switch the whole book to docusaurus as well :) |
Looks good, I'll give it a try. |
Btw @Desdaemon what do you think about the doc site? (Since you have written several chapters) |
It looks great! I might contribute some translations myself if it works out well. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
👀 |
Busy with other things, but maybe next week will be free to continue 😵 |
Signed-off-by: trdthg <trdthg47@gmail.com>
Signed-off-by: trdthg <trdthg47@gmail.com>
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.
Good job! I am going to merge it, maybe after the fix of broken homepage if it is easy to fix
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.
Continuing this thread: @trdthg - what about adding this information at the top of each zh
page, saying something like:
This page is translated by [@trdthg](https://github.com/trdthg)
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
# ref https://github.com/peaceiris/actions-mdbook | ||
- name: Setup mdBook | ||
uses: peaceiris/actions-mdbook@v1 | ||
with: | ||
mdbook-version: 'latest' | ||
|
||
- name: Setup `mdbook-mermaid` | ||
run: cargo install mdbook-mermaid | ||
- name: Setup Rust cache | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install mdbook | ||
run: cargo install mdbook --locked --version 0.4.28 | ||
|
||
- name: Install mdbook-mermaid | ||
run: cargo install mdbook-mermaid --locked --version 0.12.6 | ||
|
||
- name: Install mdbook-i18n-helpers | ||
run: cargo install mdbook-i18n-helpers --locked --version 0.1.0 | ||
|
||
- name: Build book in English | ||
working-directory: ./book | ||
run: mdbook build -d book | ||
|
||
- run: mdbook build ./book | ||
- name: Build all translations | ||
working-directory: ./book | ||
run: | | ||
for po_lang in ${{ env.LANGUAGES }}; do | ||
echo "::group::Building $po_lang translation" | ||
MDBOOK_BOOK__LANGUAGE=$po_lang \ | ||
MDBOOK_OUTPUT__HTML__SITE_URL=/flutter-rust-bridge/$po_lang/ \ | ||
mdbook build -d book/$po_lang | ||
echo "::endgroup::" | ||
done |
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.
nit: it seems good to move them to justfile
. Then, everyone who wants to play with it locally (including you and me ;) ) can execute a one-line command like just whatever-command-name
instead of copy-and-paste these long code
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.
what about adding this information at the top of each zh page
Not bad, what about the people who contribute to the same page afterward?
But in any case, with the current translation process, it seems not so easy to add additional information to the translated page
Blank lines are filtered, same sentences from different pages will also be merged:
#: src/SUMMARY.md:34 src/SUMMARY.md:112
msgid "Async in Rust"
msgstr ""
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.
it seems good to move them to justfile
agree, one thing to note is that if you want to serve all languages, you will have to first build and then use a separate http server to serve them, such as https://github.com/TheWaWaR/simple-http-server
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.
Not bad, what about the people who contribute to the same page afterward?
Good question. Maybe just list all and add a link pointing to a separate page showing everyone's detailed contribution?
But in any case, with the current translation process, it seems not so easy to add additional information to the translated page
Just a wild guess, Is it possible to modify the HTML?
agree, one thing to note is that if you want to serve all languages, you will have to first build and then use a separate http server to serve them, such as TheWaWaR/simple-http-server
I see. Then it would be great to have a bit of doc, telling users how to build and serve the doc locally
Signed-off-by: trdthg <trdthg47@gmail.com>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hey @fzyzcjy! Yes, I need to release a new version to get this fixed. Thanks for the ping! I didn't do this yet since I have been working on a way to improve the text extraction. The current 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, upgrade our own PO files, and also update the publishing pipeline to use the new version. |
Hi @fzyzcjy, I've finally released a version 0.2 of mdbook-i18n-helpers — which improves the way text is extracted and which fixed the rendering of the badges on the translated pages: https://google.github.io/comprehensive-rust/pt-BR. I know this PR is closed, but if you ever end up using the plugins, please add a link to your project in the mdbook-i18n-helpers README. |
@mgeisler Sure! I am happy to see i18n support, this PR is closed by stale bot. |
@trdthg Feel free to ping me when everything is done and I am happy to reopen/merge! |
Add gettext and i18n support
This is still a draft now, I want to discuss some questions here.
I have tried to use code from rust-lang/mdBook#1864 and rust-lang/mdBook#1306, and found a bug there. It was fixed quickly. This translation process is feasible, but both of them are not merged yet, so configuring the environment is a little complicated.