forked from onepercentclub/onepercentclub-site
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtranslations.sh
executable file
·170 lines (137 loc) · 6.12 KB
/
translations.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
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
#!/bin/sh
# Generate, compile, fetch and upload PO-files for the site
# Generate will create PO files.
# It wil run through some modules that will group some apps together
# e.g. Members:
# echo "Generating PO-files for members"
# cd "$APPS_ROOT/members"
# INCLUDES="--include=$BB_ROOT/bb_accounts"
# It will cd to apps/members and then generate PO file including strings for bb_accounts
SOURCE_LANGUAGE="en"
MANAGE_PY="$PWD/manage.py"
SETTINGS=""
if [ $2 ]; then
SETTINGS="--settings=$2"
fi
ROOT="$PWD"
APPS_ROOT="$PWD/apps"
BB_ROOT="$PWD/env/src/bluebottle/bluebottle"
MAKEMESSAGES="$MANAGE_PY makemessages -l $SOURCE_LANGUAGE --no-wrap -e hbs,html,txt $SETTINGS"
MAKEJSMESSAGES="$MANAGE_PY makemessages -l $SOURCE_LANGUAGE --include=env/src/bluebottle/bluebottle --ignore=djangojs.js --ignore=node_modules --no-wrap -e js -i compressed -d djangojs $SETTINGS"
COMPILEMESSAGES="$MANAGE_PY compilemessages $SETTINGS"
COMPILEJSMESSAGES="$MANAGE_PY compilejsi18n $SETTINGS"
APPS_DIR="apps"
# All apps that hold translations. This is used by `pull` and `compile`.
APPS="projects members fundraisers organizations tasks homepage donations"
case "$1" in
generate)
echo "Let's create some PO-files!"
echo "Generating PO-files for members"
cd "$APPS_ROOT/members"
INCLUDES="--include=$BB_ROOT/bb_accounts"
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
$MANAGE_PY makemessages -l $SOURCE_LANGUAGE $INCLUDES --no-wrap -e hbs,html,txt $SETTINGS
echo "Generating PO-files for projects"
cd "$APPS_ROOT/projects"
INCLUDES="--include=$BB_ROOT/bb_projects"
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
$MANAGE_PY makemessages -l $SOURCE_LANGUAGE $INCLUDES --no-wrap -e hbs,html,txt $SETTINGS
echo "Generating PO-files for fundraisers"
cd "$APPS_ROOT/fundraisers"
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
$MANAGE_PY makemessages -l $SOURCE_LANGUAGE --no-wrap -e hbs,html,txt $SETTINGS
echo "Generating PO-files for organizations"
cd "$APPS_ROOT/organizations"
INCLUDES="--include=$BB_ROOT/bb_organizations"
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
$MANAGE_PY makemessages -l $SOURCE_LANGUAGE $INCLUDES --no-wrap -e hbs,html,txt $SETTINGS
echo "Generating PO-files for tasks"
cd "$APPS_ROOT/tasks"
INCLUDES="--include=$BB_ROOT/bb_tasks"
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
$MANAGE_PY makemessages -l $SOURCE_LANGUAGE $INCLUDES --no-wrap -e hbs,html,txt $SETTINGS
echo "Generating PO-files for wallposts, pages, news and homepage, and utils and common in BB"
cd "$APPS_ROOT/homepage"
INCLUDES=" --include=$ROOT/templates --include=$APPS_ROOT/core/ --include=$BB_ROOT/wallposts --include=$BB_ROOT/pages --include=$BB_ROOT/quotes --include=$BB_ROOT/slides --include=$BB_ROOT/contact --include=$BB_ROOT/news --include=$BB_ROOT/utils --include=$BB_ROOT/common"
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
$MANAGE_PY makemessages -l $SOURCE_LANGUAGE $INCLUDES --no-wrap -e hbs,html,txt $SETTINGS
echo "Generating PO-files for donations and payments"
cd "$APPS_ROOT/donations"
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
INCLUDES="--include=$APPS_ROOT/fund --include=$APPS_ROOT/payouts --include=$APPS_ROOT/cowry --include=$APPS_ROOT/cowry_docdata --include=$APPS_ROOT/cowry_docdata_legacy"
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/LC_MESSAGES/django.po
$MANAGE_PY makemessages -l $SOURCE_LANGUAGE $INCLUDES --no-wrap -e hbs,html,txt $SETTINGS
echo "Generating PO-file for javascripts"
cd "$APPS_ROOT/.."
# Make the locale dir if it's not there.
if [ ! -d "locale" ]; then
mkdir "locale"
fi
# Remove the old translations
rm locale/en/djangojs.po
$MAKEJSMESSAGES
;;
push)
echo "Uploading PO files to Transifex"
tx push -s
;;
pull)
echo "Fetching PO files from Transifex"
tx pull -a -f
# Copy en_GB translations to en
for APP_DIR in $APPS; do
DIR="apps/$APP_DIR"
cp $DIR/locale/en_GB/LC_MESSAGES/*.po $DIR/locale/en/LC_MESSAGES/
done
;;
compile)
echo "Compiling PO files"
for APP_DIR in $APPS; do
DIR="apps/$APP_DIR"
echo "Compiling PO-file for $DIR"
(cd $DIR && $COMPILEMESSAGES)
done
echo "Generating PO-file for javascript"
$COMPILEMESSAGES
$COMPILEJSMESSAGES
;;
*)
echo $"Usage: $0 {generate|push|pull|compile}"
exit 1
esac