Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit c42a4a9

Browse files
committed
feat: create i18.sh script and hook it to github action
- The script runs on merge, will generate .tx directory. - .tx contains transifex config files of *specific* edx-doc projects, the files will be used by tx-client in order to push resources. - Both sphinx-intl and tx-client libraries are being used and thus are added to the dependency. - TX_TOKEN is expected to be available in the env with push permission, for more info refer to: https://docs.transifex.com/client/client-configuration - Related ticket: https://trello.com/c/q4JJOHeo
1 parent 98bc1f6 commit c42a4a9

File tree

8 files changed

+210
-59
lines changed

8 files changed

+210
-59
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@ jobs:
3838
- name: "Build docs"
3939
run: |
4040
./run_tests.sh
41+
42+
- name : "Translations Sync"
43+
if: ${{ github.event.pull_request.merged }}
44+
env:
45+
TX_TOKEN: ${{ secrets.TX_TOKEN }}
46+
run: |
47+
./i18n.sh
48+
tx push -s
49+

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ clean: ## remove built html files
3232

3333
test: ## build all the docs
3434
./run_tests.sh
35+
i18n: ## Generate pot files followed by tx configuration
36+
./i18n.sh

i18n.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
# This script purpose is to ease process needed to support i18n
4+
# for the doc. It does that by first generating pot from the
5+
# rst files of a selected projects using sphinx to generate gettext
6+
# (which outputs the pot files) and then the next step
7+
# is to use sphinx-intl to write to the ./tx/config file, hence
8+
# this script cerates the ./tx/config file. Note: if the file,
9+
# already exists it will be overwritten!.
10+
# This script assumes sphinx-intl is already installed as well,
11+
# It can be installed by `pip install sphinx-intl`
12+
# For more information, about sphinx-intl please visit:
13+
# https://www.sphinx-doc.org/en/master/usage/advanced/intl.html
14+
15+
16+
# Check if this script is running by github, and if it's
17+
# missing the token then exit.
18+
if [ "$CI" = true ] && [ -z "$TX_TOKEN" ]; then
19+
echo 'Running cancelled, missing TX_TOKEN!'
20+
exit 1
21+
fi
22+
23+
# Root directory
24+
BASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
25+
# Config file
26+
TX_CONFIG_FILE=$BASE_DIR/.tx/config
27+
28+
# Success exit message, wrapped in green color.
29+
EXIT_MESSAGE="\033[0;32mYou should now be able to push the files using tx client \n
30+
Typically this done by 'tx push -s', please note: you should have \n
31+
already installed tx client and configured it such that there is \n
32+
a project called 'open-edx-documentation-project' in the organization \n
33+
and that you already have authenticated with in '~/.transifexrc', \n
34+
for more information, please visit: \n
35+
https://docs.transifex.com/client/client-configuration.\033[0m"
36+
37+
# Preparing the config file:
38+
rm -rf .tx
39+
mkdir $BASE_DIR/.tx
40+
touch $TX_CONFIG_FILE
41+
echo "[main]" >> $TX_CONFIG_FILE
42+
echo "host = https://www.transifex.com" >> $TX_CONFIG_FILE
43+
44+
45+
# The set of books to run translations for.
46+
# Currently this is only a subset of the books in this repo because we are in the middle of
47+
# assesing which books will remain a part of openedx and which ones are actually specific
48+
# to edx.org
49+
projects=(
50+
"en_us/open_edx_students"
51+
"en_us/open_edx_course_authors"
52+
"en_us/open_edx_release_notes"
53+
)
54+
55+
# Iterating over each project defined above, to generate the pot the files
56+
# and then mapping the files accordingly in the tx config file
57+
for project in "${projects[@]}"; do
58+
cd $BASE_DIR/$project
59+
echo "--> Start generating the pot files for ${project#'en_us/'}"
60+
61+
# Extract translatable messages into pot files
62+
make gettext
63+
64+
# Adding the pot files to tx config file
65+
echo "--> Start writing tx configuration for the ${project#'en_us/'}"
66+
67+
cd $BASE_DIR
68+
sphinx-intl update-txconfig-resources \
69+
--pot-dir $BASE_DIR/$project/build/locale/ \
70+
--locale-dir $BASE_DIR/$project/locales/ \
71+
--transifex-project-name open-edx-documentation-project
72+
done
73+
74+
# Todo: Check for errors and set exit message accordingly
75+
76+
echo -e ${EXIT_MESSAGE}
77+
78+

requirements/base.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
edx-sphinx-theme # edX theme for the generated documentation
55
sphinx # Documentation builder
6+
sphinx-intl # For creating i18n strings
7+
transifex-client # For pushing the i18n resources

requirements/base.txt

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,66 @@
11
#
2-
# This file is autogenerated by pip-compile
2+
# This file is autogenerated by pip-compile with python 3.8
33
# To update, run:
44
#
55
# make upgrade
66
#
77
alabaster==0.7.12
88
# via sphinx
99
babel==2.9.1
10-
# via sphinx
11-
certifi==2021.5.30
12-
# via requests
13-
chardet==4.0.0
14-
# via requests
15-
docutils==0.16
1610
# via
17-
# -c requirements/common_constraints.txt
1811
# sphinx
19-
edx-sphinx-theme==2.1.0
12+
# sphinx-intl
13+
certifi==2021.10.8
14+
# via requests
15+
charset-normalizer==2.0.9
16+
# via requests
17+
click==8.0.3
18+
# via sphinx-intl
19+
docutils==0.17.1
20+
# via sphinx
21+
edx-sphinx-theme==3.0.0
2022
# via -r requirements/base.in
21-
idna==2.10
23+
gitdb==4.0.9
24+
# via gitpython
25+
gitpython==3.1.24
26+
# via transifex-client
27+
idna==3.3
2228
# via requests
23-
imagesize==1.2.0
29+
imagesize==1.3.0
2430
# via sphinx
25-
jinja2==3.0.1
31+
jinja2==3.0.3
2632
# via sphinx
2733
markupsafe==2.0.1
2834
# via jinja2
29-
packaging==20.9
35+
packaging==21.3
3036
# via sphinx
31-
pygments==2.9.0
37+
pygments==2.10.0
3238
# via sphinx
33-
pyparsing==2.4.7
39+
pyparsing==3.0.6
3440
# via packaging
35-
pytz==2021.1
41+
python-slugify==4.0.1
42+
# via transifex-client
43+
pytz==2021.3
3644
# via babel
37-
requests==2.25.1
38-
# via sphinx
45+
requests==2.26.0
46+
# via
47+
# sphinx
48+
# transifex-client
3949
six==1.16.0
40-
# via edx-sphinx-theme
41-
snowballstemmer==2.1.0
50+
# via
51+
# edx-sphinx-theme
52+
# transifex-client
53+
smmap==5.0.0
54+
# via gitdb
55+
snowballstemmer==2.2.0
4256
# via sphinx
43-
sphinx==4.0.2
57+
sphinx==4.3.1
4458
# via
4559
# -r requirements/base.in
4660
# edx-sphinx-theme
61+
# sphinx-intl
62+
sphinx-intl==2.0.1
63+
# via -r requirements/base.in
4764
sphinxcontrib-applehelp==1.0.2
4865
# via sphinx
4966
sphinxcontrib-devhelp==1.0.2
@@ -56,8 +73,16 @@ sphinxcontrib-qthelp==1.0.3
5673
# via sphinx
5774
sphinxcontrib-serializinghtml==1.1.5
5875
# via sphinx
59-
urllib3==1.26.5
60-
# via requests
76+
text-unidecode==1.3
77+
# via python-slugify
78+
transifex-client==0.14.3
79+
# via -r requirements/base.in
80+
typing-extensions==4.0.1
81+
# via gitpython
82+
urllib3==1.26.7
83+
# via
84+
# requests
85+
# transifex-client
6186

6287
# The following packages are considered to be unsafe in a requirements file:
6388
# setuptools

requirements/common_constraints.txt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313

1414

1515
# using LTS django version
16-
Django<2.3
16+
Django<3.3
1717

18-
# docutils version 0.17 is causing docs rendering to fail
19-
# See https://sourceforge.net/p/docutils/bugs/417/
20-
docutils==0.16
21-
22-
# latest version is causing e2e failures in edx-platform.
23-
drf-jwt<1.19.1
24-
25-
# Newer versions causing tests failures in multiple repos.
26-
pyjwt[crypto]==1.7.1
18+
# elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process.
19+
# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html
20+
elasticsearch<7.14.0

requirements/dev.txt

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# This file is autogenerated by pip-compile
2+
# This file is autogenerated by pip-compile with python 3.8
33
# To update, run:
44
#
55
# make upgrade
@@ -12,74 +12,99 @@ babel==2.9.1
1212
# via
1313
# -r requirements/base.txt
1414
# sphinx
15-
certifi==2021.5.30
15+
# sphinx-intl
16+
certifi==2021.10.8
1617
# via
1718
# -r requirements/base.txt
1819
# requests
19-
chardet==4.0.0
20+
charset-normalizer==2.0.9
2021
# via
2122
# -r requirements/base.txt
2223
# requests
23-
click==8.0.1
24-
# via pip-tools
25-
docutils==0.16
24+
click==8.0.3
25+
# via
26+
# -r requirements/base.txt
27+
# pip-tools
28+
# sphinx-intl
29+
docutils==0.17.1
2630
# via
2731
# -r requirements/base.txt
2832
# sphinx
29-
edx-sphinx-theme==2.1.0
33+
edx-sphinx-theme==3.0.0
3034
# via -r requirements/base.txt
31-
idna==2.10
35+
gitdb==4.0.9
36+
# via
37+
# -r requirements/base.txt
38+
# gitpython
39+
gitpython==3.1.24
40+
# via
41+
# -r requirements/base.txt
42+
# transifex-client
43+
idna==3.3
3244
# via
3345
# -r requirements/base.txt
3446
# requests
35-
imagesize==1.2.0
47+
imagesize==1.3.0
3648
# via
3749
# -r requirements/base.txt
3850
# sphinx
39-
jinja2==3.0.1
51+
jinja2==3.0.3
4052
# via
4153
# -r requirements/base.txt
4254
# sphinx
4355
markupsafe==2.0.1
4456
# via
4557
# -r requirements/base.txt
4658
# jinja2
47-
packaging==20.9
59+
packaging==21.3
4860
# via
4961
# -r requirements/base.txt
5062
# sphinx
51-
pep517==0.10.0
63+
pep517==0.12.0
5264
# via pip-tools
53-
pip-tools==6.1.0
65+
pip-tools==6.4.0
5466
# via -r requirements/dev.in
55-
pygments==2.9.0
67+
pygments==2.10.0
5668
# via
5769
# -r requirements/base.txt
5870
# sphinx
59-
pyparsing==2.4.7
71+
pyparsing==3.0.6
6072
# via
6173
# -r requirements/base.txt
6274
# packaging
63-
pytz==2021.1
75+
python-slugify==4.0.1
76+
# via
77+
# -r requirements/base.txt
78+
# transifex-client
79+
pytz==2021.3
6480
# via
6581
# -r requirements/base.txt
6682
# babel
67-
requests==2.25.1
83+
requests==2.26.0
6884
# via
6985
# -r requirements/base.txt
7086
# sphinx
87+
# transifex-client
7188
six==1.16.0
7289
# via
7390
# -r requirements/base.txt
7491
# edx-sphinx-theme
75-
snowballstemmer==2.1.0
92+
# transifex-client
93+
smmap==5.0.0
94+
# via
95+
# -r requirements/base.txt
96+
# gitdb
97+
snowballstemmer==2.2.0
7698
# via
7799
# -r requirements/base.txt
78100
# sphinx
79-
sphinx==4.0.2
101+
sphinx==4.3.1
80102
# via
81103
# -r requirements/base.txt
82104
# edx-sphinx-theme
105+
# sphinx-intl
106+
sphinx-intl==2.0.1
107+
# via -r requirements/base.txt
83108
sphinxcontrib-applehelp==1.0.2
84109
# via
85110
# -r requirements/base.txt
@@ -104,12 +129,25 @@ sphinxcontrib-serializinghtml==1.1.5
104129
# via
105130
# -r requirements/base.txt
106131
# sphinx
107-
toml==0.10.2
132+
text-unidecode==1.3
133+
# via
134+
# -r requirements/base.txt
135+
# python-slugify
136+
tomli==1.2.2
108137
# via pep517
109-
urllib3==1.26.5
138+
transifex-client==0.14.3
139+
# via -r requirements/base.txt
140+
typing-extensions==4.0.1
141+
# via
142+
# -r requirements/base.txt
143+
# gitpython
144+
urllib3==1.26.7
110145
# via
111146
# -r requirements/base.txt
112147
# requests
148+
# transifex-client
149+
wheel==0.37.0
150+
# via pip-tools
113151

114152
# The following packages are considered to be unsafe in a requirements file:
115153
# pip

0 commit comments

Comments
 (0)