From 13b4f7182c0e0d3b66a2c0c6be69bdbd9865bbce Mon Sep 17 00:00:00 2001 From: bmuenzenmeyer Date: Thu, 7 Nov 2024 11:45:25 +0000 Subject: [PATCH 01/11] chore: add wip action --- .github/workflows/translations-pr2.yml | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/translations-pr2.yml diff --git a/.github/workflows/translations-pr2.yml b/.github/workflows/translations-pr2.yml new file mode 100644 index 0000000000000..0aa9019aa46c3 --- /dev/null +++ b/.github/workflows/translations-pr2.yml @@ -0,0 +1,39 @@ +name: Crowdin Action + +on: + push: + branches: [main] + +jobs: + synchronize-with-crowdin: + runs-on: ubuntu-latest + + steps: + - name: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + with: + egress-policy: audit + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: crowdin action + uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 + with: + upload_sources: true + upload_translations: false + download_translations: true + localization_branch_name: chore/crowdin + create_pull_request: true + pull_request_title: 'New Crowdin Translations' + pull_request_body: 'New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)' + pull_request_base_branch_name: 'main' + env: + # A classic GitHub Personal Access Token with the 'repo' scope selected (the user should have write access to the repository). + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + + # A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + + # Visit https://crowdin.com/settings#api-key to create this token + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} From f3c0c44cff88bc8e727f38e09d0098bf6a8137f4 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Thu, 21 Nov 2024 09:49:53 -0600 Subject: [PATCH 02/11] feat: automated crowdin sync --- ...ml => translations-pr-lint-and-format.yml} | 3 +- .github/workflows/translations-pr2.yml | 39 -------------- .github/workflows/translations-sync.yml | 51 +++++++++++++++++++ crowdin.yml | 6 +-- 4 files changed, 55 insertions(+), 44 deletions(-) rename .github/workflows/{translations-pr.yml => translations-pr-lint-and-format.yml} (97%) delete mode 100644 .github/workflows/translations-pr2.yml create mode 100644 .github/workflows/translations-sync.yml diff --git a/.github/workflows/translations-pr.yml b/.github/workflows/translations-pr-lint-and-format.yml similarity index 97% rename from .github/workflows/translations-pr.yml rename to .github/workflows/translations-pr-lint-and-format.yml index f3dce60376045..681d9a6108538 100644 --- a/.github/workflows/translations-pr.yml +++ b/.github/workflows/translations-pr-lint-and-format.yml @@ -1,7 +1,8 @@ # This Workflow is used to comment on PRs that have changes that touch Translated Files # and then comments on their PRs mentioning that they should not do so +# It also formats incoming content because it is often not adherent to our rules post-translation. -name: Crowdin Checks +name: Incoming Translation Checks on: pull_request_target: diff --git a/.github/workflows/translations-pr2.yml b/.github/workflows/translations-pr2.yml deleted file mode 100644 index 0aa9019aa46c3..0000000000000 --- a/.github/workflows/translations-pr2.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Crowdin Action - -on: - push: - branches: [main] - -jobs: - synchronize-with-crowdin: - runs-on: ubuntu-latest - - steps: - - name: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 - with: - egress-policy: audit - - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: crowdin action - uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 - with: - upload_sources: true - upload_translations: false - download_translations: true - localization_branch_name: chore/crowdin - create_pull_request: true - pull_request_title: 'New Crowdin Translations' - pull_request_body: 'New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)' - pull_request_base_branch_name: 'main' - env: - # A classic GitHub Personal Access Token with the 'repo' scope selected (the user should have write access to the repository). - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - - # A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api - CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} - - # Visit https://crowdin.com/settings#api-key to create this token - CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} diff --git a/.github/workflows/translations-sync.yml b/.github/workflows/translations-sync.yml new file mode 100644 index 0000000000000..194f4ccfc9371 --- /dev/null +++ b/.github/workflows/translations-sync.yml @@ -0,0 +1,51 @@ +# This action automates the synchronization of our crowdin translations, so that a human does not need to kick it off from the crowdin UI +# See translations-pr-line-and-format.yml for quality control we conduct on ingress of new translations. +name: Crowdin Sync + +on: + schedule: + - cron: '0 5 * * 5' # At 05:00 on Fridays. This guarantees that we have the 72 hour weekend time to review translations. + +# Cancel any runs on the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + # These permissions required by `crowdin/github-action` + contents: write + pull-requests: write + +jobs: + synchronize-with-crowdin: + runs-on: ubuntu-latest + + steps: + - name: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + with: + egress-policy: audit + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # see all the options at https://github.com/crowdin/github-action + - name: crowdin action + uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 + with: + upload_sources: true + upload_translations: false #do not upload existing translations - this is a one-way operation + # the rest of this controls how the PR comes in with new translations + download_translations: true + localization_branch_name: chore/crowdin + create_pull_request: true + pull_request_title: '[automated]: crowdin sync' + pull_request_body: 'New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)' + pull_request_labels: github_actions:pull-request + commit_message: 'chore: synced translations from crowdin [skip ci]' + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + # A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + # Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} diff --git a/crowdin.yml b/crowdin.yml index 644c8d597bf99..e2c04f56dde08 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -1,8 +1,6 @@ -commit_message: 'chore: synced translations from crowdin [skip ci]' +project_id_env: 'CROWDIN_PROJECT_ID' +api_token_env: 'CROWDIN_PERSONAL_TOKEN' append_commit_message: false -pull_request_title: '[automated]: crowdin sync' -pull_request_labels: - - 'github_actions:pull-request' files: - source: /apps/site/pages/en/**/*.md translation: /apps/site/pages/%two_letters_code%/**/%original_file_name% From 1f17c612f3b84384d4318d0e419d0cf30fca9aec Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Thu, 21 Nov 2024 10:16:29 -0600 Subject: [PATCH 03/11] add dry run, workflow_dispatch --- .github/workflows/translations-sync.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/translations-sync.yml b/.github/workflows/translations-sync.yml index 194f4ccfc9371..bbc62b57eb0b6 100644 --- a/.github/workflows/translations-sync.yml +++ b/.github/workflows/translations-sync.yml @@ -3,6 +3,7 @@ name: Crowdin Sync on: + workflow_dispatch: # Allow running when we want to, for events such as urgent translation mistakes or 100% completed languages schedule: - cron: '0 5 * * 5' # At 05:00 on Fridays. This guarantees that we have the 72 hour weekend time to review translations. @@ -33,8 +34,11 @@ jobs: - name: crowdin action uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 with: + # testing only + dryrun_action: true + # do not upload existing translations - this is a one-way operation upload_sources: true - upload_translations: false #do not upload existing translations - this is a one-way operation + upload_translations: false # the rest of this controls how the PR comes in with new translations download_translations: true localization_branch_name: chore/crowdin From 5a181073907875dcca33253f7e4249fad9257e96 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Thu, 21 Nov 2024 11:23:39 -0600 Subject: [PATCH 04/11] rename token --- .github/workflows/translations-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/translations-sync.yml b/.github/workflows/translations-sync.yml index bbc62b57eb0b6..9933177a0eee6 100644 --- a/.github/workflows/translations-sync.yml +++ b/.github/workflows/translations-sync.yml @@ -48,7 +48,7 @@ jobs: pull_request_labels: github_actions:pull-request commit_message: 'chore: synced translations from crowdin [skip ci]' env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} # Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot From c09d91ac1e0719522f71cc85a8c2debd074a5a77 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Thu, 21 Nov 2024 11:46:26 -0600 Subject: [PATCH 05/11] add mention of translation deployment --- TRANSLATION.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TRANSLATION.md b/TRANSLATION.md index 8f5ccd89efaf3..99c3aaa29d40d 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -87,3 +87,9 @@ Translation Keys should not be translated during Unit Testing. If your Component - Unit Tests should not rely on text, titles, or string bags, as these texts will change arbitrarily and make the test suite fail. - In this case, you should test your component by aria-text, or other `aria-*` attributes or even by class names or other artifacts. - Visual Regression Testing is recommended to test how different languages and text appear within a Component. + +## Deploying Translations + +Translations are synced between Crowdin and the repository via a cron schedule, and as needed manually by a collaborator. + +Incoming translations are linted to ensure they come from crowdin, and are also formatted to adhere to our project settings. From e35936a80241ef8cb853fde28aa70256ba545036 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Thu, 21 Nov 2024 11:51:05 -0600 Subject: [PATCH 06/11] Update .github/workflows/translations-sync.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Brian Muenzenmeyer --- .github/workflows/translations-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/translations-sync.yml b/.github/workflows/translations-sync.yml index 9933177a0eee6..4d69161ed626c 100644 --- a/.github/workflows/translations-sync.yml +++ b/.github/workflows/translations-sync.yml @@ -1,5 +1,5 @@ # This action automates the synchronization of our crowdin translations, so that a human does not need to kick it off from the crowdin UI -# See translations-pr-line-and-format.yml for quality control we conduct on ingress of new translations. +# See translations-pr-lint-and-format.yml for quality control we conduct on ingress of new translations. name: Crowdin Sync on: From 8f2c952913e0392d7e8f23c4b121aa8fe8cc9e9b Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Sat, 23 Nov 2024 11:30:22 -0600 Subject: [PATCH 07/11] docs: clarified our translation flows --- TRANSLATION.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TRANSLATION.md b/TRANSLATION.md index 99c3aaa29d40d..2b0b38210bb91 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -90,6 +90,9 @@ Translation Keys should not be translated during Unit Testing. If your Component ## Deploying Translations -Translations are synced between Crowdin and the repository via a cron schedule, and as needed manually by a collaborator. +Translations are synced between Crowdin and the repository via GitHub Actions. + +- One every push to `main`, we upload any new source content. +- Via a cron schedule, and as needed manually by a collaborator, we download completed translations. Incoming translations are linted to ensure they come from crowdin, and are also formatted to adhere to our project settings. From c61b594cc4655e8ef8e466c22bc077a7b8f57a07 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Sat, 23 Nov 2024 11:30:43 -0600 Subject: [PATCH 08/11] separate translation source upload from download --- .github/workflows/translations-sync.yml | 9 +++-- .github/workflows/translations-upload.yml | 41 +++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/translations-upload.yml diff --git a/.github/workflows/translations-sync.yml b/.github/workflows/translations-sync.yml index 4d69161ed626c..14dae4fcd1c25 100644 --- a/.github/workflows/translations-sync.yml +++ b/.github/workflows/translations-sync.yml @@ -1,6 +1,7 @@ # This action automates the synchronization of our crowdin translations, so that a human does not need to kick it off from the crowdin UI +# See translations-upload.yml for automation to upload our source content # See translations-pr-lint-and-format.yml for quality control we conduct on ingress of new translations. -name: Crowdin Sync +name: Crowdin Download on: workflow_dispatch: # Allow running when we want to, for events such as urgent translation mistakes or 100% completed languages @@ -34,10 +35,8 @@ jobs: - name: crowdin action uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 with: - # testing only - dryrun_action: true - # do not upload existing translations - this is a one-way operation - upload_sources: true + # do not upload anything - this is a one-way operation download + upload_sources: false upload_translations: false # the rest of this controls how the PR comes in with new translations download_translations: true diff --git a/.github/workflows/translations-upload.yml b/.github/workflows/translations-upload.yml new file mode 100644 index 0000000000000..2de80ab208550 --- /dev/null +++ b/.github/workflows/translations-upload.yml @@ -0,0 +1,41 @@ +# This action automates the upload of our source content to crowdin. +# See translations-sync.yml for the automation to download new translations on a schedule +# See translations-pr-lint-and-format.yml for quality control we conduct on ingress of new translations. +name: Crowdin Upload + +on: + push: + branches: [main] + +# Cancel any runs on the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + upload-to-crowdin: + runs-on: ubuntu-latest + + steps: + - name: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + with: + egress-policy: audit + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # see all the options at https://github.com/crowdin/github-action + - name: crowdin action + uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 + with: + # only upload sources, ensuring this is a one-way operation + upload_sources: true + upload_translations: false + download_translations: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + # Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} From 1dcdff395039b8da860540f224cc41c70dbfa084 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Sat, 23 Nov 2024 18:57:21 -0600 Subject: [PATCH 09/11] Update TRANSLATION.md Co-authored-by: Michael Esteban Signed-off-by: Brian Muenzenmeyer --- TRANSLATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TRANSLATION.md b/TRANSLATION.md index 2b0b38210bb91..fa36471837cc6 100644 --- a/TRANSLATION.md +++ b/TRANSLATION.md @@ -92,7 +92,7 @@ Translation Keys should not be translated during Unit Testing. If your Component Translations are synced between Crowdin and the repository via GitHub Actions. -- One every push to `main`, we upload any new source content. +- On every push to `main`, we upload any new source content. - Via a cron schedule, and as needed manually by a collaborator, we download completed translations. Incoming translations are linted to ensure they come from crowdin, and are also formatted to adhere to our project settings. From 7d27852985b30d5e5a39ad07f0065e079388ce09 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Thu, 5 Dec 2024 07:16:47 -0600 Subject: [PATCH 10/11] Update .github/workflows/translations-sync.yml Co-authored-by: Claudio W Signed-off-by: Brian Muenzenmeyer --- .github/workflows/translations-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/translations-sync.yml b/.github/workflows/translations-sync.yml index 14dae4fcd1c25..2c492b2da07f4 100644 --- a/.github/workflows/translations-sync.yml +++ b/.github/workflows/translations-sync.yml @@ -33,7 +33,7 @@ jobs: # see all the options at https://github.com/crowdin/github-action - name: crowdin action - uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 + uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da # v2.3.0 with: # do not upload anything - this is a one-way operation download upload_sources: false From 7a64c0431bfcfb99a3c8f1a4f6af5b5bf3c5b862 Mon Sep 17 00:00:00 2001 From: Brian Muenzenmeyer Date: Thu, 5 Dec 2024 07:16:56 -0600 Subject: [PATCH 11/11] Update .github/workflows/translations-upload.yml Co-authored-by: Claudio W Signed-off-by: Brian Muenzenmeyer --- .github/workflows/translations-upload.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/translations-upload.yml b/.github/workflows/translations-upload.yml index 2de80ab208550..5344797cb67d8 100644 --- a/.github/workflows/translations-upload.yml +++ b/.github/workflows/translations-upload.yml @@ -27,7 +27,7 @@ jobs: # see all the options at https://github.com/crowdin/github-action - name: crowdin action - uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da #v2.3.0 + uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da # v2.3.0 with: # only upload sources, ensuring this is a one-way operation upload_sources: true