forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 5
195 lines (161 loc) · 6.28 KB
/
generate-translations.yml
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Dispatch - Generate Transifex and Translatewiki translations
on:
workflow_dispatch:
inputs:
theme_branch:
description: 'Theme Branch'
required: false
default: 'develop'
jobs:
generate-translations:
name: Detect changed source and generate Transifex and Translatewiki translations
runs-on: ubuntu-20.04
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install OS requirements
run: |
sudo apt-get update --fix-missing
sudo apt-get install pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl gettext
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
- name: Check TX Version
run: |
export PATH="$PWD:$PATH"
tx --version
- name: Install pip requirements
run: |
python3 -m pip install pip==20.0.2
python3 -m pip install setuptools==60.9.3
python3 -m pip install wheel==0.37.1
pip install --disable-pip-version-check --exists-action w -r requirements/edx/development.txt
- name: Clone edx-theme repo
id: clone-theme-repo
uses: actions/checkout@v3
with:
repository: wikimedia/wikilearn-edx-theme
path: ./themes
ref: ${{ inputs.theme_branch }}
token: ${{ secrets.THEME_ACCESS_TOKEN }}
- name: Checkout master as feature branch does not exist
uses: actions/checkout@v3
with:
repository: wikimedia/wikilearn-edx-theme
path: ./themes
ref: master
token: ${{ secrets.THEME_ACCESS_TOKEN }}
if: steps.clone-theme-repo.outcome == 'failure'
- name: Pull latest translations from Transifex
id: pull-latest-translations-from-transifex
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
TX_HOSTNAME: https://rest.api.transifex.com
run: |
export PATH="$PWD:$PATH"
export NO_PREREQ_INSTALL='true'
export LMS_CFG=$(pwd)/lms/devstack.yml
export STUDIO_CFG=$(pwd)/cms/devstack.yml
python manage.py cms translatewiki pull_transifex_translations
unset LMS_CFG
unset STUDIO_CFG
- name: Generate translations for changed source
id: generate-new-translations
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
run: make extract_translations
- name: Merge all the translations
id: merge-translations-edx
run: |
export NO_PREREQ_INSTALL='true'
export LMS_CFG=$(pwd)/lms/devstack.yml
export STUDIO_CFG=$(pwd)/cms/devstack.yml
python manage.py cms translatewiki msgmerge
unset LMS_CFG
unset STUDIO_CFG
- name: Merge translations from translatewiki & manual files
id: merge-translations-translatewiki
run: |
export NO_PREREQ_INSTALL='true'
export LMS_CFG=$(pwd)/lms/devstack.yml
export STUDIO_CFG=$(pwd)/cms/devstack.yml
python manage.py cms translatewiki update_from_version
python manage.py cms translatewiki remove_bad_msgstr
unset LMS_CFG
unset STUDIO_CFG
- name: Delete qqq folder if exists
id: delete-qqq-files
run: rm -r conf/locale/qqq
continue-on-error: true
- name: generate i18n files
id: generate-i18n-files
run: |
paver i18n_fastgenerate
msgattrib --no-obsolete --set-fuzzy conf/locale/en/LC_MESSAGES/wm-django.po -o conf/locale/en/LC_MESSAGES/wm-django.po
msgattrib --no-obsolete --set-fuzzy conf/locale/en/LC_MESSAGES/wm-djangojs.po -o conf/locale/en/LC_MESSAGES/wm-djangojs.po
continue-on-error: true
- name: Check errors
run: |
export NO_PREREQ_INSTALL='true'
export LMS_CFG=$(pwd)/lms/devstack.yml
export STUDIO_CFG=$(pwd)/cms/devstack.yml
django-admin.py compilemessages
i18n_tool validate
unset LMS_CFG
unset STUDIO_CFG
exit 1
if: steps.generate-i18n-files.outcome != 'success'
- name: Compile JS translations
id: compile-js-i18n-files
run: |
export NO_PREREQ_INSTALL='true'
export LMS_CFG=$(pwd)/lms/devstack.yml
export STUDIO_CFG=$(pwd)/cms/devstack.yml
paver i18n_compilejs
unset LMS_CFG
unset STUDIO_CFG
- name: Genereate custom strings
id: generate-custom-strings
env:
TX_TOKEN: ${{ secrets.TX_TOKEN }}
TX_HOSTNAME: https://rest.api.transifex.com
run: |
export PATH="$PWD:$PATH"
export NO_PREREQ_INSTALL='true'
export LMS_CFG=$(pwd)/lms/devstack.yml
export STUDIO_CFG=$(pwd)/cms/devstack.yml
python manage.py cms translatewiki generate_custom_strings
unset LMS_CFG
unset STUDIO_CFG
- name: Restore qqq files
run: git restore conf/locale/qqq/
continue-on-error: true
- name: Create Pull Request and commit changed translation files
id: cpr
uses: peter-evans/create-pull-request@v4
with:
branch: 'gitflow/auto-generated-translations'
commit-message: 'Add changed translation files'
add-paths: |
conf/locale/**/LC_MESSAGES/wm-django.po
conf/locale/**/LC_MESSAGES/wm-djangojs.po
conf/locale/**/LC_MESSAGES/django.mo
conf/locale/**/LC_MESSAGES/django.po
conf/locale/**/LC_MESSAGES/djangojs.po
conf/locale/**/LC_MESSAGES/djangojs.mo
lms/static/js/i18n/**/djangojs.js
cms/static/js/i18n/**/djangojs.js
token: ${{ secrets.EDX_PLATFORM_ACCESS_TOKEN }}
signoff: true
delete-branch: true
- name: Auto Merge Changes
id: merge-changes
uses: peter-evans/enable-pull-request-automerge@v2
with:
token: ${{ secrets.EDX_PLATFORM_ACCESS_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash
if: steps.cpr.outputs.pull-request-operation == 'created'