Skip to content

Commit 81147a6

Browse files
committed
translation: Move site verification after downloading all languages
Do not attempt to verify correctness of the website before refreshing all languages. If any structural change happened (rename, permalink change etc), it will fail because of the old files, not the freshly downloaded ones. Make htmlproofer postprocessing script language agnostic. This is mostly about removing "language" parameter, which wasn't used anyway.
1 parent 94c246a commit 81147a6

File tree

4 files changed

+36
-38
lines changed

4 files changed

+36
-38
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# to be run from the git root
3+
# $1 is directory where translated files reside and language needs to be added to internal urls
4+
# TODO param check
5+
6+
set -e
7+
8+
echo "================================= build site =================================="
9+
#read b
10+
bundle exec jekyll b
11+
12+
all_ok=true
13+
echo "================================= run htmlproofer ==============================="
14+
htmlproofer ./_site --disable-external --checks-to-ignore ImageCheck --file-ignore "./_site/video-tours/index.html,./_site/.*/video-tours/index.html" --url-ignore "/qubes-issues/" --log-level debug 2&> /tmp/html.output || all_ok=false
15+
16+
# exit here if all is ok
17+
if $all_ok; then
18+
echo 'All checks passed!'
19+
exit
20+
fi
21+
22+
echo "================================== as a last resort in case of errors process html proofer errors ================================="
23+
python3 _utils/_translation_utils/postprocess_htmlproofer.py /tmp/html.output "$1"
24+
25+
echo "================================= build the site and run htmlproofer ===================================="
26+
rm -rf ./_site/
27+
bundle exec jekyll b
28+
htmlproofer ./_site --disable-external --checks-to-ignore ImageCheck --file-ignore "./_site/video-tours/index.html,./_site/.*/video-tours/index.html" --url-ignore "/qubes-issues/" --log-level debug

_utils/_translation_utils/post_transifex_pull.sh

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,3 @@ python3 _utils/_translation_utils/postprocess_translation.py "$1" "$2" /tmp/tx-
2525
echo "============================ post processing step 4 press to cont ======================================"
2626
#read b
2727
bash _utils/_translation_utils/postprocess_translation.sh "$1" "$2" /tmp/translated_href_urls.txt
28-
29-
30-
echo "================================= build site =================================="
31-
#read b
32-
bundle exec jekyll b
33-
34-
all_ok=true
35-
echo "================================= run htmlproofer ==============================="
36-
htmlproofer ./_site --disable-external --checks-to-ignore ImageCheck --file-ignore "./_site/video-tours/index.html,./_site/$1/video-tours/index.html" --url-ignore "/qubes-issues/" --log-level debug 2&> /tmp/html.output || all_ok=false
37-
38-
# exit here if all is ok
39-
if $all_ok; then
40-
echo 'All checks passed!'
41-
exit
42-
fi
43-
44-
echo "================================== as a last resort in case of errors process html proofer errors ================================="
45-
python3 _utils/_translation_utils/postprocess_htmlproofer.py "$1" /tmp/html.output "$2"
46-
47-
echo "================================= build the site and run htmlproofer ===================================="
48-
rm -rf ./_site/
49-
bundle exec jekyll b
50-
htmlproofer ./_site --disable-external --checks-to-ignore ImageCheck --file-ignore "./_site/video-tours/index.html,./_site/$1/video-tours/index.html" --url-ignore "/qubes-issues/" --log-level debug

_utils/_translation_utils/postprocess_htmlproofer.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/python3
22
'''
3-
python _utils/_translation_utils/postprocess_htmlproofer.py <LANG> <OUTPUT_FROM_HTMLPROOFER> <TRANSLATED_DIRECTORY>
3+
python _utils/_translation_utils/postprocess_htmlproofer.py <OUTPUT_FROM_HTMLPROOFER> <TRANSLATED_DIRECTORY>
44
invoke: python _utils/_translation_utils/postprocess_htmlproofer.py de /tmp/html.output _translated/de/
5-
<LANG>[de]: translation language
65
<OUTPUT_FROM_HTMLPROOFER>[/tmp/html.output]: output from htmlproofer
76
<TRANSLATED_DIRECTORY>[_translated/de/]: the directory with the downloaded translated files from transifex
87
'''
@@ -123,12 +122,11 @@ def process_markdown(translated_file, internal_links):
123122

124123

125124

126-
def get_all_translated_permalinks_and_redirects_to_file_mapping(translated_dir, lang):
125+
def get_all_translated_permalinks_and_redirects_to_file_mapping(translated_dir):
127126
"""
128-
traverse the already updated (via tx pull) root directory with all the translated files for a specific language
129-
and get their permalinks and redirects without the specific language
130-
translated_dir: root directory with all the translated files for a specific language
131-
lang: the specific language
127+
traverse the already updated (via tx pull) root directory with all the translated files
128+
and get their permalinks and redirects
129+
translated_dir: root directory with all the translated files
132130
return: set holding the translated permalinks and redirects
133131
"""
134132
mapping = {}
@@ -246,8 +244,6 @@ def process_yml(translated, errorlinks):
246244
if __name__ == '__main__':
247245
# python _utils/_translation_utils/postprocess_htmlproofer.py de /tmp/html.output _translated/de/
248246
parser = ArgumentParser()
249-
# for which language should we do this
250-
parser.add_argument("language")
251247
# the file containing the output of htmlproofer
252248
parser.add_argument("htmlproofer_output")
253249
# the directory containing the translated (downloaded via tx pull) files
@@ -262,11 +258,6 @@ def process_yml(translated, errorlinks):
262258
logger.error("please check your translated directory")
263259
exit(1)
264260

265-
if not args.language in TRANSLATED_LANGS:
266-
print("language not in the expected translation languages")
267-
logger.error("please check your translation language")
268-
exit(1)
269-
270261
if not isfile(args.htmlproofer_output):
271262
print("please check your html proofer output file")
272263
logger.error("please check your html proofer output file")
@@ -293,7 +284,7 @@ def process_yml(translated, errorlinks):
293284
logger.debug("------------------------------------------------")
294285
logger.debug("------------------------------------------------")
295286

296-
mapping, yml_files = get_all_translated_permalinks_and_redirects_to_file_mapping(args.translated_dir, args.language)
287+
mapping, yml_files = get_all_translated_permalinks_and_redirects_to_file_mapping(args.translated_dir)
297288

298289

299290
log_debug('mapping ', mapping)

_utils/transifex-pull

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ for lang in "$@"; do
2323
bash _utils/_translation_utils/post_transifex_pull.sh "$lang" _translated/"$lang"
2424
done
2525

26+
bash _utils/_translation_utils/check_all_langs.sh _translated
27+
2628
# switch to ssh for push
2729
git -C _translated remote set-url origin [email protected]:QubesOS/qubes-translated
2830

0 commit comments

Comments
 (0)