-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranslate.sh
executable file
·65 lines (55 loc) · 1.52 KB
/
translate.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
#!/bin/sh
SINGULAR_OLD_TERM="$1"
PLURAL_OLD_TERM="$2"
SINGULAR_TERM="$3"
PLURAL_TERM="$4"
LOCALE="$5"
# build po/mo files
LC_FILES_DIR="ckanext/fjelltopp_theme/i18n/$LOCALE/LC_MESSAGES"
PO_FILE="$LC_FILES_DIR/ckanext-fjelltopp-theme.po"
MO_FILE="$LC_FILES_DIR/ckanext-fjelltopp-theme.mo"
# Remove existing PO file if it exists
if [ -f "$PO_FILE" ]; then
echo "Removing existing PO file..."
rm "$PO_FILE" || {
echo "Error: Failed to remove existing PO file"
exit 1
}
fi
# Initialize new catalog
echo "Initializing translation catalog..."
python setup.py init_catalog --locale $LOCALE || {
echo "Error: Failed to initialize catalog"
exit 1
}
# Verify PO file was created
if [ ! -f "$PO_FILE" ]; then
echo "Error: PO file was not created"
exit 1
fi
# Process the translations
echo "Processing translations..."
python "term_changer.py" "$PO_FILE" "$SINGULAR_OLD_TERM" "$PLURAL_OLD_TERM" "$SINGULAR_TERM" "$PLURAL_TERM" || {
echo "Error: Failed to process translations"
exit 1
}
# Remove existing MO file if it exists
if [ -f "$MO_FILE" ]; then
echo "Removing existing MO file..."
rm "$MO_FILE" || {
echo "Error: Failed to remove existing MO file"
exit 1
}
fi
# Compile the catalog
echo "Compiling..."
python setup.py compile_catalog || {
echo "Error: Failed to compile catalog"
exit 1
}
# Verify MO file was created
if [ ! -f "$MO_FILE" ]; then
echo "Error: MO file was not created"
exit 1
fi
echo "Translation catalog successfully updated and compiled"