Skip to content

Commit

Permalink
Sync src/ with date in PO file when publishing
Browse files Browse the repository at this point in the history
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 update all the files around the Markdown files: this allows
us to fix things in the theme, for example.

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.
  • Loading branch information
mgeisler committed Sep 24, 2023
1 parent a9183eb commit 312452c
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 21 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ env:

jobs:
publish:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# with:
# We need the full history for the restore commands below.
# fetch-depth: 0

- name: Setup Rust cache
uses: ./.github/workflows/setup-rust-cache
Expand All @@ -47,8 +47,20 @@ jobs:
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 "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 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
Expand Down
2 changes: 1 addition & 1 deletion po/bn.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-05\n"
"PO-Revision-Date: \n"
"Last-Translator: Md. Rasel Mandol <[email protected]>\n"
"Language-Team: noob_rasel<[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion po/da.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-24\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/de.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-19\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/el.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-08-26\n"
"PO-Revision-Date: 2023-08-25 13:24-0700\n"
"Last-Translator: root <[email protected]>\n"
"Language-Team: Greek <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion po/es.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-11\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/fa.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-08-23\n"
"PO-Revision-Date: 2023-08-08 21:41+0330\n"
"Last-Translator: danny <[email protected]>\n"
"Language-Team: Persian\n"
Expand Down
2 changes: 1 addition & 1 deletion po/fr.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-17\n"
"PO-Revision-Date: 2023-09-12 14:14-0400\n"
"Last-Translator: Olivier Charrez <[email protected]>\n"
"Language-Team: French <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion po/id.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-08-26\n"
"PO-Revision-Date: 2023-08-25 14:03-0700\n"
"Last-Translator: Aji Prio Sejati <[email protected]>\n"
"Language-Team: Indonesian <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion po/it.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-19\n"
"PO-Revision-Date: 2023-09-19 09:35+0100\n"
"Last-Translator: Ivan De Marino <[email protected]>\n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/ja.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-24\n"
"PO-Revision-Date: 2023-06-06 13:18+0900\n"
"Last-Translator: Kenta Aratani <[email protected]>\n"
"Language-Team: Japanese <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion po/ko.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: [한국어]Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-24\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/pl.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-08-26\n"
"PO-Revision-Date: 2023-08-25 14:19-0700\n"
"Last-Translator: Kuba Jaroszewski <[email protected]>\n"
"Language-Team: Polish <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion po/pt-BR.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-08-28\n"
"PO-Revision-Date: 2023-08-25 09:32-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/ru.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-08\n"
"PO-Revision-Date: 2023-08-25 14:28-0700\n"
"Last-Translator: Yauheni Baltukha <[email protected]>\n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/tr.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-08-26\n"
"PO-Revision-Date: 2023-08-25 14:48-0700\n"
"Last-Translator: [email protected]\n"
"Language-Team: Turkish <[email protected]>\n"
Expand Down
2 changes: 1 addition & 1 deletion po/uk.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-19\n"
"PO-Revision-Date: 2023-09-12 22:06+0000\n"
"Last-Translator: Andrew Kushyk <[email protected]>\n"
"Language-Team: \n"
Expand Down
2 changes: 1 addition & 1 deletion po/zh-CN.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-09-18\n"
"PO-Revision-Date: 2023-06-12 21:28-0700\n"
"Last-Translator: Zhengping Jiang <[email protected]>\n"
"Language-Team: Language zh-Hans\n"
Expand Down
2 changes: 1 addition & 1 deletion po/zh-TW.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Comprehensive Rust 🦀\n"
"POT-Creation-Date: \n"
"POT-Creation-Date: 2023-08-23\n"
"PO-Revision-Date: 2023-06-02 14:43+0800\n"
"Last-Translator: Hank Chen <[email protected]>\n"
"Language-Team: Traditional Chinese (Taiwan) <[email protected]>\n"
Expand Down

0 comments on commit 312452c

Please sign in to comment.