From dc2807b566cc92b61e4e3fcc26c3f8980368de4d Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Mon, 18 Oct 2021 15:08:44 +0200 Subject: [PATCH 1/2] Free contributors from i18n data sync responsibility --- .github/workflows/check-i18n-task.yml | 50 +++---------------- .github/workflows/i18n-nightly-push.yaml | 3 ++ .github/workflows/i18n-weekly-pull.yaml | 2 + Taskfile.yml | 8 --- docs/CONTRIBUTING.md | 16 ------ i18n/cmd/commands/transifex/pull_transifex.go | 3 -- 6 files changed, 12 insertions(+), 70 deletions(-) diff --git a/.github/workflows/check-i18n-task.yml b/.github/workflows/check-i18n-task.yml index 5346a7c36ce..ff5835d5a76 100644 --- a/.github/workflows/check-i18n-task.yml +++ b/.github/workflows/check-i18n-task.yml @@ -6,53 +6,15 @@ env: # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows on: - create: push: - paths: - - ".github/workflows/check-i18n-task.ya?ml" - - "Taskfile.ya?ml" - - "go.mod" - - "go.sum" - - "**.go" - - "i18n/**" - pull_request: - paths: - - ".github/workflows/check-i18n-task.ya?ml" - - "Taskfile.ya?ml" - - "go.mod" - - "go.sum" - - "**.go" - - "i18n/**" + branches: + # Release branches have names like 0.8.x, 0.9.x, ... + - "[0-9]+.[0-9]+.x" workflow_dispatch: repository_dispatch: jobs: - run-determination: - runs-on: ubuntu-latest - outputs: - result: ${{ steps.determination.outputs.result }} - steps: - - name: Determine if the rest of the workflow should run - id: determination - run: | - RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" - # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead. - if [[ \ - "${{ github.event_name }}" != "create" || \ - "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \ - ]]; then - # Run the other jobs. - RESULT="true" - else - # There is no need to run the other jobs. - RESULT="false" - fi - - echo "::set-output name=result::$RESULT" - check: - needs: run-determination - if: needs.run-determination.outputs.result == 'true' runs-on: ubuntu-latest steps: @@ -70,5 +32,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} version: 3.x - - name: Check for errors - run: task i18n:check + - name: Check i18n source file is up to date + run: + - task i18n:update + - task i18n:check diff --git a/.github/workflows/i18n-nightly-push.yaml b/.github/workflows/i18n-nightly-push.yaml index 8849481f841..7c8ff550d91 100644 --- a/.github/workflows/i18n-nightly-push.yaml +++ b/.github/workflows/i18n-nightly-push.yaml @@ -26,6 +26,9 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} version: 3.x + - name: Run task i18n:update + run: task i18n:update + - name: Run task i18n:push run: task i18n:push env: diff --git a/.github/workflows/i18n-weekly-pull.yaml b/.github/workflows/i18n-weekly-pull.yaml index c08ada9066d..828b5fa1e7c 100644 --- a/.github/workflows/i18n-weekly-pull.yaml +++ b/.github/workflows/i18n-weekly-pull.yaml @@ -4,6 +4,8 @@ on: schedule: # run every monday at 2AM - cron: "0 2 * * 1" + workflow_dispatch: + repository_dispatch: jobs: pull-from-transifex: diff --git a/Taskfile.yml b/Taskfile.yml index 164eba510c5..ee54db4f33d 100755 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -261,13 +261,11 @@ tasks: desc: Updates i18n files cmds: - go run ./i18n/cmd/main.go catalog generate . > ./i18n/data/en.po - - task: i18n:generate i18n:pull: desc: Pull i18n files from transifex cmds: - go run ./i18n/cmd/main.go transifex pull ./i18n/data - - task: i18n:generate i18n:push: desc: Push i18n files to transifex @@ -281,12 +279,6 @@ tasks: - git add -N ./i18n/data - git diff --exit-code ./i18n/data - i18n:generate: - desc: Generate embedded i18n catalog files - cmds: - - git add -N ./i18n/data - - git diff --exit-code ./i18n/data &> /dev/null - # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-mkdocs-task/Taskfile.yml website:check: desc: Check whether the MkDocs-based website will build diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 765f00a352e..419cdcc61e4 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -322,22 +322,6 @@ In order to support i18n in the CLI, any messages that are intended to be transl `i18n.Tr`. This call allows us to build a catalog of translatable strings, replacing the reference string at runtime with the localized value. -Adding or modifying these messages requires an i18n update, as this process creates the reference catalog that is shared -with translators. For that reason, the `task check` command will fail if the catalog was not updated to sync with -changes to the source code. - -To update the catalog, execute the following command and commit the changes. - -```shell -task i18n:update -``` - -To verify that the catalog is up-to-date, you may execute the command: - -```shell -task i18n:check -``` - Example usage: ```golang diff --git a/i18n/cmd/commands/transifex/pull_transifex.go b/i18n/cmd/commands/transifex/pull_transifex.go index ad7212188ed..af9c90b19b1 100644 --- a/i18n/cmd/commands/transifex/pull_transifex.go +++ b/i18n/cmd/commands/transifex/pull_transifex.go @@ -70,9 +70,6 @@ func getLanguages() []string { var langs []string for key := range jsonResp { - if key == "en" { - continue - } langs = append(langs, key) } From b2f5b67833e675416989e71e5a08c25491282d59 Mon Sep 17 00:00:00 2001 From: Silvano Cerza <3314350+silvanocerza@users.noreply.github.com> Date: Tue, 19 Oct 2021 11:26:51 +0200 Subject: [PATCH 2/2] Update .github/workflows/check-i18n-task.yml Co-authored-by: per1234 --- .github/workflows/check-i18n-task.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/check-i18n-task.yml b/.github/workflows/check-i18n-task.yml index ff5835d5a76..3d7689aa6f9 100644 --- a/.github/workflows/check-i18n-task.yml +++ b/.github/workflows/check-i18n-task.yml @@ -33,6 +33,4 @@ jobs: version: 3.x - name: Check i18n source file is up to date - run: - - task i18n:update - - task i18n:check + run: task i18n:check