-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathupdate_translations.sh
More file actions
51 lines (43 loc) · 1.4 KB
/
update_translations.sh
File metadata and controls
51 lines (43 loc) · 1.4 KB
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
#!/bin/bash
set -e
DOMAIN="bigcontrolcenter"
POT_FILE="bigcontrolcenter/locale/$DOMAIN.pot"
echo "Generating file list..."
# Find all Python files
find bigcontrolcenter -name "*.py" | sort >files_to_translate.txt
echo "Extracting strings to $POT_FILE..."
# Extract strings
# --no-location to avoid noise in diffs if lines change often? No, usually we want locations.
# But verify if content has location. Yes it does.
xgettext --files-from=files_to_translate.txt \
--language=Python \
--keyword=_ \
--keyword=N_ \
--output="$POT_FILE" \
--from-code=UTF-8 \
--package-name="BigControlCenter" \
--package-version="1.0" \
--copyright-holder="BigLinux Team" \
--add-comments=Note:
echo "Generating Shell file list..."
find bigcontrolcenter -name "*.sh" -o -name "*.sh.htm" | sort >shell_files_to_translate.txt
echo "Extracting Shell strings to $POT_FILE..."
# Extract Shell strings and join
xgettext --files-from=shell_files_to_translate.txt \
--language=Shell \
--keyword=$ \
--join-existing \
--output="$POT_FILE" \
--from-code=UTF-8 \
--add-comments=Note:
echo "Updating PO files..."
# Merge with existing PO files
for po_file in bigcontrolcenter/locale/*.po; do
echo "Updating $po_file..."
msgmerge --update --backup=none "$po_file" "$POT_FILE"
# Remove obsolete strings
msgattrib --no-obsolete -o "$po_file" "$po_file"
done
# Cleanup
rm files_to_translate.txt shell_files_to_translate.txt
echo "Done."