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

Translation: Newer simplified Chinese #292

Open Fomalhauthmj opened 2 years ago

Fomalhauthmj commented 2 years ago

In last two weeks, I read this book and did my best to translate it into a newer simplified Chinese translation. Maybe we can add a translation list in readme for those who want read in native language?.πŸ€” The translation repo is here .

simonsan commented 2 years ago

As long as mdbook doesn't support i18n we should probably create a new sections for 'translations' in SUMMARY.md and collect them there.

pickfire commented 2 years ago

@Fomalhauthmj I think can just use the usual approach when i18n is not support, put the translated link in README. Let me submit a pull request for this.

simonsan commented 1 year ago

Reopening: We are refactoring to a new translation system that should make it easier.

CC: #352 #345

@Fomalhauthmj Would you be able to adopt your translation when we are ready?

Fomalhauthmj commented 1 year ago

Of course, I will review my translation again in the spare time for a better reading experience.

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. So take you time, really.

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

simonsan commented 1 year ago

The translation system is merged πŸš€ and translations are now supported in this repository.

Please read here how translations can be updated/added. If any further help is needed setting it up, please tag me.

Fomalhauthmj commented 1 year ago

Ok, I have learned how to work with po files.When my translation being prepared, I will open a pr on main branch.

simonsan commented 1 year ago

Ok, I have learned how to work with po files.When my translation being prepared, I will open a pr on main branch.

I prepared some CI stuff already, so when your PR comes, we need to set it up for a first translation. It shouldn't be a lot of work, but please make sure maintainers can edit your branch so we can help setting up the very first translation. πŸ‘πŸ½

simonsan commented 1 year ago

I'm working on a German translation in #359 so I will make the initial setup there. Within your PR for another language, we would only need to add stuff to the language picker and CI manually. πŸ‘πŸ½

Fomalhauthmj commented 1 year ago

@simonsan , I found that messages.pot file doesn't contain corresponding quote links, check this file, the following contents can't found in messages.pot.

[associated function]: https://doc.rust-lang.org/stable/book/ch05-03-method-syntax.html#associated-functions
[std-default]: https://doc.rust-lang.org/stable/std/default/trait.Default.html
[std-or-default]: https://doc.rust-lang.org/stable/std/?search=or_default
[API Guidelines/C-COMMON-TRAITS]: https://rust-lang.github.io/api-guidelines/interoperability.html#types-eagerly-implement-common-traits-c-common-traits
simonsan commented 1 year ago

Need to investigate that the next days. Thanks for bringing it up. It could be also related to markdown formatting in https://github.com/google/mdbook-i18n-helpers/issues/19 so will also double check if that could be an upstream issue as well

Fomalhauthmj commented 1 year ago

I have checked the process of create_catalog in mdbook-i18n-helpers, use following test function:

    fn my_test() -> anyhow::Result<()> {
        let (ctx, _tmp) = create_render_context(&[
            ("book.toml", "[book]"),
            ("src/SUMMARY.md", "- [The Foo Chapter](foo.md)"),
            (
                "src/foo.md",
                "this is a quota link [name1][ref1].\n\n[ref1]:test_url\n",
            ),
        ])?;

        let catalog = create_catalog(&ctx)?;

        for msg in catalog.messages() {
            assert!(!msg.is_translated());
        }
        Ok(())
    }

And,the events we got are:

Start(Paragraph) -- "this is a quota link [name1][ref1].\n"
Text(Borrowed("this is a quota link ")) -- "this is a quota link "
Start(Link(Reference, Borrowed("test_url"), Borrowed(""))) -- "[name1][ref1]"
Text(Borrowed("name1")) -- "name1"
End(Link(Reference, Borrowed("test_url"), Borrowed(""))) -- "[name1][ref1]"
Text(Borrowed(".")) -- "."
End(Paragraph) -- "this is a quota link [name1][ref1].\n"

It seems like that we need make sure that [ref1] shouldn't be translated for correct reference-style links. In this way, the reference-style links can work fine as usual.