From 9a856b1c379ab29715e2dbc0ae96d8ba426ddb87 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sun, 24 Sep 2023 18:14:49 +0200 Subject: [PATCH] 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 https://github.com/google/mdbook-i18n-helpers/issues/16. The logic here should eventually be moved to somewhere in mdbook-i18n-helpers, most likely to the renderer that @sakex is building in https://github.com/google/mdbook-i18n-helpers/pull/84. --- .github/workflows/publish.yml | 53 ++++++++++++++++++++--------------- po/da.po | 2 +- po/ko.po | 2 +- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1573c215a1f6..0da3e0161938 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,15 +1,16 @@ name: Publish on: - push: - branches: - - main - workflow_dispatch: + pull_request: +# push: +# branches: +# - main +# workflow_dispatch: -permissions: - contents: read - pages: write - id-token: write +#permissions: +# contents: read +# pages: write +# id-token: write # Allow one concurrent deployment concurrency: @@ -23,9 +24,9 @@ env: jobs: publish: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} +# environment: +# name: github-pages +# url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout @@ -45,8 +46,16 @@ jobs: - name: Build all translations run: | + set -x + 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 + git checkout "main@{$POT_CREATION_DATE}" src/ + else + git checkout src/ + fi MDBOOK_BOOK__LANGUAGE=$po_lang \ MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \ mdbook build -d book/$po_lang @@ -55,14 +64,14 @@ jobs: echo "::endgroup::" done - - name: Setup Pages - uses: actions/configure-pages@v2 - - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - path: book/html - - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 +# - name: Setup Pages +# uses: actions/configure-pages@v2 +# +# - name: Upload artifact +# uses: actions/upload-pages-artifact@v1 +# with: +# path: book/html +# +# - name: Deploy to GitHub Pages +# id: deployment +# uses: actions/deploy-pages@v1 diff --git a/po/da.po b/po/da.po index 5c5bf87b0cbe..6b235342480a 100644 --- a/po/da.po +++ b/po/da.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Comprehensive Rust 🦀\n" -"POT-Creation-Date: \n" +"POT-Creation-Date: 2023-09-24T14:16:08+02:00\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" diff --git a/po/ko.po b/po/ko.po index 4ead7487e525..61e313535dfb 100644 --- a/po/ko.po +++ b/po/ko.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: [한국어]Comprehensive Rust 🦀\n" -"POT-Creation-Date: \n" +"POT-Creation-Date: 2023-08-24T14:16:08+02:00\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n"