Localization of The Rust Edition Guide

Announcement

We’re glad to announce that the :tada: rust-edition-guide-l10n :tada: project is now published:

The goal of this project is to translate The Rust Edition Guide into multiple languages. Translations are contributed via the Crowdin platform, automatically synchronized with the GitHub repository, and can be previewed on GitHub Pages.

How to Contribute Translations?

To contribute the translations, please follow the following steps:

  1. Create an account on Crowdin Enterprise if you don’t have one.
  2. Log in and go to the rust-edition-guide-l10n project.
  3. Choose the target language you would like to contribute.

If the target language is not yet supported, please open an issue to request the new language. Once the requested language is added, you can start translating.

How to Reuse Translations?

If the upstream project or anyone wants to reuse the .po files maintained by the this project, they can download the .po files from the po/<version> branch with the following command:

git clone --branch=po/<version> https://github.com/localizethedocs/rust-edition-guide-l10n.git <locale-dir>

Those po/<version> branches are created to facilitate reusage by the upstream project. For instance, the zh_TW documentation for the nightly version can be generated using the demo commands below:

Click to expand the demo commands
BRANCH=main
VERSION=nightly
LANGUAGE=zh_TW
RENDERER=html
REPODIR=$(pwd)/rust-edition-guide
VENVDIR=$REPODIR/.venv

# Prepare the repository and environment
git clone --branch=$BRANCH --depth=1 \
    --recurse-submodules \
    --shallow-submodules \
    https://github.com/rust-lang/rust.git \
    $REPODIR
cd $REPODIR
conda create --prefix $VENVDIR --yes
conda activate $VENVDIR
export PYTHONNOUSERSITE=1
export CARGO_INSTALL_ROOT=$VENVDIR
conda install rust=1 dasel=2 jq -c conda-forge -c nodefaults --yes
cargo install mdbook@^0.5 mdbook-i18n-helpers@^0.4

# Clone the .po files to the 'locale' directory
rm -rf $REPODIR/src/doc/edition-guide/locale
git clone --branch=po/$VERSION \
    https://github.com/localizethedocs/rust-edition-guide-l10n.git \
    $REPODIR/src/doc/edition-guide/locale

# Build the documentation
pushd $REPODIR/src/doc/edition-guide
MDBOOK_BOOK__SRC=src \
MDBOOK_BOOK__LANGUAGE=$LANGUAGE \
MDBOOK_OUTPUT="{\"$RENDERER\":$(dasel -f $(pwd)/book.toml "output.$RENDERER" -w json)}" \
MDBOOK_PREPROCESSOR__GETTEXT=$(jq -n -c '{"after":["links"],"po-dir":"locale"}') \
mdbook build $(pwd) --dest-dir $(pwd)/book/$LANGUAGE
popd

# Preview the documentation
firefox $REPODIR/src/doc/edition-guide/book/$LANGUAGE/index.html