-
Notifications
You must be signed in to change notification settings - Fork 42
/
build-locales.sh
executable file
·69 lines (59 loc) · 1.85 KB
/
build-locales.sh
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
#!/bin/bash
export TZ="Europe/Berlin"
mkdir -p ./logs
# Get the directory where the script is located
SCRIPT_DIR=$(dirname "$(realpath "$0")")
SCRIPT_NAME=$(basename "$0")
build_all=false
# Parse input arguments
for arg in "$@"; do
case $arg in
--all-languages)
build_all=true
shift
;;
*) ;;
esac
done
# Change to the script's directory
cd "$SCRIPT_DIR" || exit 1
# Load the environment variables
if [ -f "$SCRIPT_DIR/.env" ]; then
source "$SCRIPT_DIR/.env"
else
current_time=$(date +"%Y-%m-%d %H:%M:%S")
log_message="$current_time [$SCRIPT_NAME] Environment file not found!"
echo -e "$log_message" >> "$LOGFILE_PATH/webhook.log"
exit 1
fi
# #
# Generate .pot files based on .rst sources
# #
current_time=$(date +"%Y-%m-%d %H:%M:%S")
log_message="$current_time [$SCRIPT_NAME] Generating .pot files with sphinx-build based on .rst sources"
echo -e "$log_message" >> "$LOGFILE_PATH/webhook.log"
docker compose run --rm gettext sphinx-build -b gettext . /docs/locales
log_message="$current_time [$SCRIPT_NAME] Done"
# #
# Generate locales for all languages (.po files)
# based on .pot files generated by "sphinx-build -b gettext"
# #
sphinx_args=""
for lang in "${PRIORITY_LANGUAGES[@]}"
do
if [ "$lang" != "en" ]; then # no need to build locales for English source language
sphinx_args="$sphinx_args -l $lang"
fi
done
if [ "$build_all" = true ]; then
sphinx_args=""
for lang in "${OTHER_LANGUAGES[@]}"
do
sphinx_args="$sphinx_args -l $lang"
done
fi
current_time=$(date +"%Y-%m-%d %H:%M:%S")
log_message="$current_time [$SCRIPT_NAME] Generating .po files based on .pot files generated by sphinx-build"
echo -e "$log_message" >> "$LOGFILE_PATH/webhook.log"
docker compose run --rm intl sphinx-intl update -p /docs/locales/ $sphinx_args
log_message="$current_time [$SCRIPT_NAME] Done"