-
-
Notifications
You must be signed in to change notification settings - Fork 766
Expand file tree
/
Copy pathregenerate_english_userDocs_translation_source.yml
More file actions
119 lines (109 loc) · 4.4 KB
/
regenerate_english_userDocs_translation_source.yml
File metadata and controls
119 lines (109 loc) · 4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Rebuild English User Documentation for Translation
on:
push:
branches:
- beta
paths:
- 'user_docs/en/*.md'
permissions:
actions: write
jobs:
rebuild-translation-source:
runs-on: windows-2025
steps:
- name: Early exit
shell: bash
run: |
if [ -z "${{ vars.CROWDIN_PROJECT_ID }}" ]; then
echo "CROWDIN_PROJECT_ID is not set. Exiting workflow."
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.NVACCESSAUTO_PUSH_PAT }}
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.13'
architecture: 'x86'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install lxml requests
- name: update xliff files
shell: pwsh
run: |
# for any English markdown files changed within the commits of this push,
# update the corresponding xliff file (if one exists) to reflect the current markdown file,
# keeping existing translation IDs in tact.
$PSNativeCommandUseErrorActionPreference = $true
$ErrorActionPreference = 'Stop'
$changedFiles = git diff --name-only ${{github.event.before}}.. -- user_docs/en/*.md
foreach ($file in $changedFiles) {
Write-Host "$file has changed"
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($file)
$xliff = "user_docs/en/$baseName.xliff"
$tempXliff = "user_docs/en/$baseName.xliff.temp"
$markdown = $file
if (Test-Path $xliff) {
Write-Host "Updating $xliff with changes from $markdown"
python source/markdownTranslate.py updateXliff -x $xliff -m $file -o $tempXliff
Write-Host "Renaming $tempXliff to $xliff"
move-item -Path $tempXliff -Destination $xliff -Force
} else {
Write-Host "Ignoring $markdown as it does not have a corresponding xliff file"
}
}
if: success()
- name: Commit and Push changes
run: |
$ErrorActionPreference = 'Stop'
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
$filesChanged = git diff --name-only -- *.xliff
if ($filesChanged) {
Write-Host "xliff files were changed. Committing and pushing changes."
foreach ($file in $filesChanged) {
git add $file
Write-Host "Committing $file"
git commit -m "Update $file"
}
Write-Host "Pushing changes"
git push origin HEAD
} else {
Write-Host "No xliff files were changed. Skipping commit and push."
}
if: success()
- name: Crowdin upload
# This step must only be run after successfully pushing changes to the repository.
# Otherwise if the push fails, subsequent runs may cause new translation IDs to be created,
# which will cause needless retranslation of existing strings.
env:
crowdinProjectID: ${{ vars.CROWDIN_PROJECT_ID }}
crowdinAuthToken: ${{ secrets.CROWDIN_AUTH_TOKEN }}
run: |
# Check if we changed userGuide.xliff in this action.
# If we did, upload it to Crowdin.
$ErrorActionPreference = 'Stop'
$changed = git diff --name-only ${{GITHUB.SHA}}.. -- user_docs/en/userGuide.xliff
if ($changed) {
Write-Host "Uploading userGuide.xliff to Crowdin"
# 18 is the file ID for userGuide.xliff in Crowdin.
python ci/scripts/crowdinSync.py uploadSourceFile 18 user_docs/en/userguide.xliff
} else {
Write-Host "Not uploading userGuide.xliff to Crowdin as it has not changed"
}
$changed = git diff --name-only ${{GITHUB.SHA}}.. -- user_docs/en/changes.xliff
if ($changed) {
Write-Host "Uploading changes.xliff to Crowdin"
# 20 is the file ID for changes.xliff in Crowdin.
python ci/scripts/crowdinSync.py uploadSourceFile 20 user_docs/en/changes.xliff
} else {
Write-Host "Not uploading changes.xliff to Crowdin as it has not changed"
}