mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-15 13:26:37 +02:00
Sync src/
with date in PO file when publishing (#1243)
Before, we always used the latest English source files when publishing. This means that translations become outdated as soon as anything is changed in the source. This PR changes will instead freeze translations in place: they will keep using the same English source files until a new POT file is merged into the translation. We do this by relying on the POT-Creation-Date field in the PO files. We still use up-to-date versions of all other files: this allows us to fix things in the theme, for example. So the assumption here is that never versions of our infrastructure remains compatible with old versions of the Markdown files. This approach has a problem: when files are moved, the English translation will link to the new name. This name will not exist in the old translations. We might be able to disable these links somehow. Part of google/mdbook-i18n-helpers#16. The logic here should eventually be moved to somewhere in mdbook-i18n-helpers, most likely to the renderer that @sakex is building in google/mdbook-i18n-helpers#84.
This commit is contained in:
parent
9d21fe159a
commit
ca966f304c
16
.github/workflows/publish.yml
vendored
16
.github/workflows/publish.yml
vendored
@ -30,6 +30,9 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
# We need the full history below.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Rust cache
|
||||
uses: ./.github/workflows/setup-rust-cache
|
||||
@ -46,9 +49,20 @@ jobs:
|
||||
- name: Build all translations
|
||||
run: |
|
||||
for po_lang in ${{ env.LANGUAGES }}; do
|
||||
echo "::group::Building $po_lang translation"
|
||||
POT_CREATION_DATE=$(grep --max-count 1 '^"POT-Creation-Date:' po/$po_lang.po | sed -E 's/".*: (.*)\\n"/\1/')
|
||||
if [[ $POT_CREATION_DATE == "" ]]; then
|
||||
POT_CREATION_DATE=now
|
||||
fi
|
||||
echo "::group::Building $po_lang translation as of $POT_CREATION_DATE"
|
||||
rm -r src/
|
||||
git restore --source "$(git rev-list -n 1 --before "$POT_CREATION_DATE" @)" src/
|
||||
|
||||
# Set language and adjust site URL. Clear the redirects
|
||||
# since they are in sync with the source files, not the
|
||||
# translation.
|
||||
MDBOOK_BOOK__LANGUAGE=$po_lang \
|
||||
MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \
|
||||
MDBOOK_OUTPUT__HTML__REDIRECT='{}' \
|
||||
mdbook build -d book/$po_lang
|
||||
(cd book/$po_lang/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
|
||||
mv book/$po_lang/html book/html/$po_lang
|
||||
|
Loading…
x
Reference in New Issue
Block a user