Skip to content

Commit a904f8e

Browse files
bmuenzenmeyerCopilotmikeestoovflowd
authored
Automated, scheduled crowdin sync (#7272)
* chore: add wip action * feat: automated crowdin sync * add dry run, workflow_dispatch * rename token * add mention of translation deployment * Update .github/workflows/translations-sync.yml Co-authored-by: Copilot <[email protected]> Signed-off-by: Brian Muenzenmeyer <[email protected]> * docs: clarified our translation flows * separate translation source upload from download * Update TRANSLATION.md Co-authored-by: Michael Esteban <[email protected]> Signed-off-by: Brian Muenzenmeyer <[email protected]> * Update .github/workflows/translations-sync.yml Co-authored-by: Claudio W <[email protected]> Signed-off-by: Brian Muenzenmeyer <[email protected]> * Update .github/workflows/translations-upload.yml Co-authored-by: Claudio W <[email protected]> Signed-off-by: Brian Muenzenmeyer <[email protected]> --------- Signed-off-by: Brian Muenzenmeyer <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Michael Esteban <[email protected]> Co-authored-by: Claudio W <[email protected]>
1 parent f571d25 commit a904f8e

5 files changed

+108
-5
lines changed

.github/workflows/translations-pr.yml .github/workflows/translations-pr-lint-and-format.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# This Workflow is used to comment on PRs that have changes that touch Translated Files
22
# and then comments on their PRs mentioning that they should not do so
3+
# It also formats incoming content because it is often not adherent to our rules post-translation.
34

4-
name: Crowdin Checks
5+
name: Incoming Translation Checks
56

67
on:
78
pull_request_target:
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This action automates the synchronization of our crowdin translations, so that a human does not need to kick it off from the crowdin UI
2+
# See translations-upload.yml for automation to upload our source content
3+
# See translations-pr-lint-and-format.yml for quality control we conduct on ingress of new translations.
4+
name: Crowdin Download
5+
6+
on:
7+
workflow_dispatch: # Allow running when we want to, for events such as urgent translation mistakes or 100% completed languages
8+
schedule:
9+
- cron: '0 5 * * 5' # At 05:00 on Fridays. This guarantees that we have the 72 hour weekend time to review translations.
10+
11+
# Cancel any runs on the same branch
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
# These permissions required by `crowdin/github-action`
18+
contents: write
19+
pull-requests: write
20+
21+
jobs:
22+
synchronize-with-crowdin:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Harden Runner
27+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
28+
with:
29+
egress-policy: audit
30+
31+
- name: Checkout
32+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
33+
34+
# see all the options at https://github.com/crowdin/github-action
35+
- name: crowdin action
36+
uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da # v2.3.0
37+
with:
38+
# do not upload anything - this is a one-way operation download
39+
upload_sources: false
40+
upload_translations: false
41+
# the rest of this controls how the PR comes in with new translations
42+
download_translations: true
43+
localization_branch_name: chore/crowdin
44+
create_pull_request: true
45+
pull_request_title: '[automated]: crowdin sync'
46+
pull_request_body: 'New Crowdin translations from the [Node.js Crowdin project](https://crowdin.com/project/nodejs-web)'
47+
pull_request_labels: github_actions:pull-request
48+
commit_message: 'chore: synced translations from crowdin [skip ci]'
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
# A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api
52+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
53+
# Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot
54+
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This action automates the upload of our source content to crowdin.
2+
# See translations-sync.yml for the automation to download new translations on a schedule
3+
# See translations-pr-lint-and-format.yml for quality control we conduct on ingress of new translations.
4+
name: Crowdin Upload
5+
6+
on:
7+
push:
8+
branches: [main]
9+
10+
# Cancel any runs on the same branch
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
upload-to-crowdin:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Harden Runner
21+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
22+
with:
23+
egress-policy: audit
24+
25+
- name: Checkout
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
28+
# see all the options at https://github.com/crowdin/github-action
29+
- name: crowdin action
30+
uses: crowdin/github-action@2d540f18b0a416b1fbf2ee5be35841bd380fc1da # v2.3.0
31+
with:
32+
# only upload sources, ensuring this is a one-way operation
33+
upload_sources: true
34+
upload_translations: false
35+
download_translations: false
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
# A numeric ID, found at https://crowdin.com/project/nodejs-web/tools/api
39+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
40+
# Created from https://crowdin.com/settings#api-key logged in using nodejs-crowdin-bot
41+
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

TRANSLATION.md

+9
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,12 @@ Translation Keys should not be translated during Unit Testing. If your Component
8787
- Unit Tests should not rely on text, titles, or string bags, as these texts will change arbitrarily and make the test suite fail.
8888
- In this case, you should test your component by aria-text, or other `aria-*` attributes or even by class names or other artifacts.
8989
- Visual Regression Testing is recommended to test how different languages and text appear within a Component.
90+
91+
## Deploying Translations
92+
93+
Translations are synced between Crowdin and the repository via GitHub Actions.
94+
95+
- On every push to `main`, we upload any new source content.
96+
- Via a cron schedule, and as needed manually by a collaborator, we download completed translations.
97+
98+
Incoming translations are linted to ensure they come from crowdin, and are also formatted to adhere to our project settings.

crowdin.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
commit_message: 'chore: synced translations from crowdin [skip ci]'
1+
project_id_env: 'CROWDIN_PROJECT_ID'
2+
api_token_env: 'CROWDIN_PERSONAL_TOKEN'
23
append_commit_message: false
3-
pull_request_title: '[automated]: crowdin sync'
4-
pull_request_labels:
5-
- 'github_actions:pull-request'
64
files:
75
- source: /apps/site/pages/en/**/*.md
86
translation: /apps/site/pages/%two_letters_code%/**/%original_file_name%

0 commit comments

Comments
 (0)