flutter_rust_bridge icon indicating copy to clipboard operation
flutter_rust_bridge copied to clipboard

Add i18n support

Open trdthg opened this issue 2 years ago • 7 comments

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 https://github.com/rust-lang/mdBook/pull/1864 and https://github.com/rust-lang/mdBook/pull/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.

trdthg avatar Sep 19 '22 12:09 trdthg

Hi! Thanks for opening this pull request! :smile:

welcome[bot] avatar Sep 19 '22 12:09 welcome[bot]

This is still a draft now

Done

This translation process is feasible, but both of them are not merged yet, so configuring the environment is a little complicated.

Hmm good question. Is it possible that, you firstly configure everything under your fork?

fzyzcjy avatar Sep 19 '22 12:09 fzyzcjy

@all-contributors please add @trdthg for doc

fzyzcjy avatar Sep 19 '22 12:09 fzyzcjy

@fzyzcjy

I've put up a pull request to add @trdthg! :tada:

allcontributors[bot] avatar Sep 19 '22 12:09 allcontributors[bot]

Is it possible that, you firstly configure everything under your fork?

Yes, It's not really that complicated, except that you have to clone two other copies of the mdBook. And then config them here.

# [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"

trdthg avatar Sep 19 '22 12:09 trdthg

Great!

Btw is the translatetool written by you? Maybe we can merge it into justfile, which has excellent support for commands, so no need for checkArgNumber etc

fzyzcjy avatar Sep 19 '22 12:09 fzyzcjy

Btw is the translatetool written by you?

Yes.

Maybe we can merge it into justfile,

Good idea. You may do some more detailed check.

trdthg avatar Sep 19 '22 12:09 trdthg

Here is the current progress.

I moved scripts to justfile and update CI workflow. After the rust 1.64 update, pr 1306 is broken, so I folked and fixed that problem. Now just and CI works.

But I don't really like this solution, and I found https://github.com/rust-lang/mdBook/issues/5#issuecomment-1258922986 today, which seems to be better. Should I switch?

trdthg avatar Oct 18 '22 05:10 trdthg

But I don't really like this solution, and I found https://github.com/rust-lang/mdBook/issues/5#issuecomment-1258922986 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 :)

fzyzcjy avatar Oct 18 '22 05:10 fzyzcjy

Looks good, I'll give it a try.

trdthg avatar Oct 18 '22 05:10 trdthg

Btw @Desdaemon what do you think about the doc site? (Since you have written several chapters)

fzyzcjy avatar Oct 18 '22 06:10 fzyzcjy

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.

Desdaemon avatar Oct 18 '22 13:10 Desdaemon

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.

stale[bot] avatar Dec 17 '22 14:12 stale[bot]

👀

fzyzcjy avatar Dec 17 '22 14:12 fzyzcjy

eyes

Busy with other things, but maybe next week will be free to continue 😵

trdthg avatar Dec 17 '22 14:12 trdthg

take your time!

fzyzcjy avatar Dec 17 '22 14:12 fzyzcjy

Hi @trdthg, I found this PR linked from https://github.com/rust-lang/mdBook/issues/5 :smile:

I see you've been using the code I wrote in https://github.com/rust-lang/mdBook/pull/1864 — I just wanted to let you know that I've updated the code to be much easier to use. You no longer need to modify mdbook itself, you just use a preprocessor (to translate) and a renderer (to extract strings). Please see https://github.com/google/comprehensive-rust/pull/130.

Feel free to drop me a comment on that PR if you try it out!

mgeisler avatar Jan 09 '23 17:01 mgeisler

👀

fzyzcjy avatar Jan 22 '23 10:01 fzyzcjy

The code in question is now released as a stand-alone crate: https://crates.io/crates/mdbook-i18n-helpers. This should let you simplify the PR here a great deal :smile:

mgeisler avatar Apr 13 '23 09:04 mgeisler

@mgeisler, Thanks for the reminder, hope my reply is not too late

Comprehensive-rust already made a good example, my solution (with modified mdbook-i18n-helpers + mdbook-i18n) seems to add extra complexity.

@fzyzcjy I think we can use the same way as it, what do you think?

trdthg avatar Apr 27 '23 09:04 trdthg

@trdthg You are feel to use any method that is simple and easy to maintain :)

fzyzcjy avatar Apr 27 '23 10:04 fzyzcjy

@mgeisler Both deleted

trdthg avatar Apr 28 '23 12:04 trdthg

image

So, I briefly checked it: https://trdthg.github.io/flutter_rust_bridge/zh/quickstart.html The "zh" mode still only contains English. Maybe I am checking the wrong location?

image

fzyzcjy avatar Apr 28 '23 13:04 fzyzcjy

The "zh" mode still only contains English.

@fzyzcjy Yes, I only translate "Introduce" in sidebar to "介绍" for now. More translations will be added gradually in other PRs.

trdthg avatar Apr 28 '23 13:04 trdthg

I see. So this PR adds the necessary code instead of translation content if I understand correctly.

fzyzcjy avatar Apr 28 '23 14:04 fzyzcjy

Seems the CI fails. Could you please check it a bit?

image

fzyzcjy avatar Apr 28 '23 14:04 fzyzcjy

Good job! I will check soon, probably within 24 hours (since quite busy recently)

fzyzcjy avatar Apr 29 '23 12:04 fzyzcjy

Firstly, seems that this is not deployed successfully?

image

fzyzcjy avatar Apr 30 '23 06:04 fzyzcjy

Btw, it seems the zh homepage is somehow broken:

image

fzyzcjy avatar May 02 '23 23:05 fzyzcjy

Btw, it seems the zh homepage is somehow broken:

@fzyzcjy seems the reason comes from mdbook-i18n-helper, after I install it from source, then build and serve locally. it's fixed image

@mgeisler I saw that compensive-rust also has this little problem, maybe you need to release a new version?

trdthg avatar May 03 '23 08:05 trdthg