Skip to content

Commit 9a856b1

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 9a856b1

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

.github/workflows/publish.yml

Lines changed: 31 additions & 22 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,9 +24,9 @@ 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
@@ -45,8 +46,16 @@ jobs:
4546

4647
- name: Build all translations
4748
run: |
49+
set -x
50+
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+
git checkout "main@{$POT_CREATION_DATE}" src/
56+
else
57+
git checkout src/
58+
fi
5059
MDBOOK_BOOK__LANGUAGE=$po_lang \
5160
MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \
5261
mdbook build -d book/$po_lang
@@ -55,14 +64,14 @@ jobs:
5564
echo "::endgroup::"
5665
done
5766
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
67+
# - name: Setup Pages
68+
# uses: actions/configure-pages@v2
69+
#
70+
# - name: Upload artifact
71+
# uses: actions/upload-pages-artifact@v1
72+
# with:
73+
# path: book/html
74+
#
75+
# - name: Deploy to GitHub Pages
76+
# id: deployment
77+
# uses: actions/deploy-pages@v1

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-24T14:16:08+02:00\n"
55
"PO-Revision-Date: \n"
66
"Last-Translator: \n"
77
"Language-Team: \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-08-24T14:16:08+02:00\n"
55
"PO-Revision-Date: \n"
66
"Last-Translator: \n"
77
"Language-Team: \n"

0 commit comments

Comments
 (0)