Skip to content

Commit 53aa98c

Browse files
committed
Sync src/ with date in PO file when publishing
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.
1 parent a9183eb commit 53aa98c

File tree

19 files changed

+58
-41
lines changed

19 files changed

+58
-41
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: Publish
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
workflow_dispatch:
4+
pull_request:
5+
# push:
6+
# branches:
7+
# - main
8+
# workflow_dispatch:
89

9-
permissions:
10-
contents: read
11-
pages: write
12-
id-token: write
10+
#permissions:
11+
# contents: read
12+
# pages: write
13+
# id-token: write
1314

1415
# Allow one concurrent deployment
1516
concurrency:
@@ -23,13 +24,15 @@ env:
2324

2425
jobs:
2526
publish:
26-
environment:
27-
name: github-pages
28-
url: ${{ steps.deployment.outputs.page_url }}
27+
# environment:
28+
# name: github-pages
29+
# url: ${{ steps.deployment.outputs.page_url }}
2930
runs-on: ubuntu-latest
3031
steps:
3132
- name: Checkout
3233
uses: actions/checkout@v3
34+
with:
35+
fetch-depth: 0 # Fetch full history
3336

3437
- name: Setup Rust cache
3538
uses: ./.github/workflows/setup-rust-cache
@@ -47,22 +50,36 @@ jobs:
4750
run: |
4851
for po_lang in ${{ env.LANGUAGES }}; do
4952
echo "::group::Building $po_lang translation"
53+
POT_CREATION_DATE=$(grep --max-count 1 '^"POT-Creation-Date:' po/$po_lang.po | sed -E 's/".*: (.*)\\n"/\1/')
54+
if [[ $POT_CREATION_DATE == "" ]]; then
55+
echo "Restoring back to start"
56+
git log -1
57+
git restore src/
58+
else
59+
echo "Restoring to $POT_CREATION_DATE"
60+
git rev-log -n 1 --before "$POT_CREATION_DATE" @
61+
echo "Restore"
62+
git restore --source "@{$POT_CREATION_DATE}" src/
63+
fi
64+
echo "Status:"
65+
git status
66+
5067
MDBOOK_BOOK__LANGUAGE=$po_lang \
5168
MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \
5269
mdbook build -d book/$po_lang
53-
(cd book/$po_lang/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
70+
#(cd book/$po_lang/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
5471
mv book/$po_lang/html book/html/$po_lang
5572
echo "::endgroup::"
5673
done
5774
58-
- name: Setup Pages
59-
uses: actions/configure-pages@v2
60-
61-
- name: Upload artifact
62-
uses: actions/upload-pages-artifact@v1
63-
with:
64-
path: book/html
65-
66-
- name: Deploy to GitHub Pages
67-
id: deployment
68-
uses: actions/deploy-pages@v1
75+
# - name: Setup Pages
76+
# uses: actions/configure-pages@v2
77+
#
78+
# - name: Upload artifact
79+
# uses: actions/upload-pages-artifact@v1
80+
# with:
81+
# path: book/html
82+
#
83+
# - name: Deploy to GitHub Pages
84+
# id: deployment
85+
# uses: actions/deploy-pages@v1

po/bn.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-05\n"
55
"PO-Revision-Date: \n"
66
"Last-Translator: Md. Rasel Mandol <[email protected]>\n"
77
"Language-Team: noob_rasel<[email protected]>\n"

po/da.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-24\n"
55
"PO-Revision-Date: \n"
66
"Last-Translator: \n"
77
"Language-Team: \n"

po/de.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-19\n"
55
"PO-Revision-Date: \n"
66
"Last-Translator: \n"
77
"Language-Team: \n"

po/el.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-08-26\n"
55
"PO-Revision-Date: 2023-08-25 13:24-0700\n"
66
"Last-Translator: root <[email protected]>\n"
77
"Language-Team: Greek <[email protected]>\n"

po/es.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-11\n"
55
"PO-Revision-Date: \n"
66
"Last-Translator: \n"
77
"Language-Team: \n"

po/fa.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-08-23\n"
55
"PO-Revision-Date: 2023-08-08 21:41+0330\n"
66
"Last-Translator: danny <[email protected]>\n"
77
"Language-Team: Persian\n"

po/fr.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-17\n"
55
"PO-Revision-Date: 2023-09-12 14:14-0400\n"
66
"Last-Translator: Olivier Charrez <[email protected]>\n"
77
"Language-Team: French <[email protected]>\n"

po/id.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-08-26\n"
55
"PO-Revision-Date: 2023-08-25 14:03-0700\n"
66
"Last-Translator: Aji Prio Sejati <[email protected]>\n"
77
"Language-Team: Indonesian <[email protected]>\n"

po/it.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-19\n"
55
"PO-Revision-Date: 2023-09-19 09:35+0100\n"
66
"Last-Translator: Ivan De Marino <[email protected]>\n"
77
"Language-Team: \n"

po/ja.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-24\n"
55
"PO-Revision-Date: 2023-06-06 13:18+0900\n"
66
"Last-Translator: Kenta Aratani <[email protected]>\n"
77
"Language-Team: Japanese <[email protected]>\n"

po/ko.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: [한국어]Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-24\n"
55
"PO-Revision-Date: \n"
66
"Last-Translator: \n"
77
"Language-Team: \n"

po/pl.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-08-26\n"
55
"PO-Revision-Date: 2023-08-25 14:19-0700\n"
66
"Last-Translator: Kuba Jaroszewski <[email protected]>\n"
77
"Language-Team: Polish <[email protected]>\n"

po/pt-BR.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-08-28\n"
55
"PO-Revision-Date: 2023-08-25 09:32-0700\n"
66
"Last-Translator: \n"
77
"Language-Team: \n"

po/ru.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-08\n"
55
"PO-Revision-Date: 2023-08-25 14:28-0700\n"
66
"Last-Translator: Yauheni Baltukha <[email protected]>\n"
77
"Language-Team: \n"

po/tr.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-08-26\n"
55
"PO-Revision-Date: 2023-08-25 14:48-0700\n"
66
"Last-Translator: [email protected]\n"
77
"Language-Team: Turkish <[email protected]>\n"

po/uk.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-19\n"
55
"PO-Revision-Date: 2023-09-12 22:06+0000\n"
66
"Last-Translator: Andrew Kushyk <[email protected]>\n"
77
"Language-Team: \n"

po/zh-CN.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-09-18\n"
55
"PO-Revision-Date: 2023-06-12 21:28-0700\n"
66
"Last-Translator: Zhengping Jiang <[email protected]>\n"
77
"Language-Team: Language zh-Hans\n"

po/zh-TW.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Comprehensive Rust 🦀\n"
4-
"POT-Creation-Date: \n"
4+
"POT-Creation-Date: 2023-08-23\n"
55
"PO-Revision-Date: 2023-06-02 14:43+0800\n"
66
"Last-Translator: Hank Chen <[email protected]>\n"
77
"Language-Team: Traditional Chinese (Taiwan) <[email protected]>\n"

0 commit comments

Comments
 (0)