-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathLANGUAGE-MANAGER
More file actions
executable file
·78 lines (61 loc) · 3.18 KB
/
LANGUAGE-MANAGER
File metadata and controls
executable file
·78 lines (61 loc) · 3.18 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
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
#!/usr/bin/env bash
DIVIDING_LINE="-----------------------------------------------------------------------------"
################################################################################################################################################################
# Extract strings from APP-MANAGER and modules
################################################################################################################################################################
[ -f ./APP-MANAGER ] && AMVERSION=$(grep "^AMVERSION=" APP-MANAGER | tr '"' '\n' | grep "^[0-9]") || AMVERSION=$(am -v)
mkdir -p translations && rm -f translations/source.*
cat <<-HEREDOC >> translations/source.pot
# File with translation for AM
# FIRST AUTHOR <EMAIL@ADDRESS>, $(date +"%Y")
msgid ""
msgstr ""
"Project-Id-Version: AM ${AMVERSION}\n"
"Report-Msgid-Bugs-To: https://github.com/ivan-hc/AM\n"
"POT-Creation-Date: $(date +"%Y-%m-%d")\n"
"PO-Revision-Date: $(date +"%Y-%m-%d")\n"
"Last-Translator: John Doe <john.doe@example.com>\n"
"Language-Team: English <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
HEREDOC
items="APP-MANAGER modules/database.am modules/install.am modules/management.am modules/sandboxes.am modules/template.am"
if [ ! -f ./APP-MANAGER ]; then
for item in $items; do
bash --dump-po-strings "/opt/am/$item" >> translations/source.pot
done
else
for item in $items; do
bash --dump-po-strings "$item" >> translations/source.pot
done
fi
msguniq translations/source.pot -o translations/source.po
msgcat --output-file=translations/source.pot --unique --indent --no-wrap translations/source.po
sed -i 's# /opt/am/# am/#g' translations/source*
if [ -s translations/source.po ] && [ -s translations/source.pot ]; then
printf "%b\nSources are updated! \n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE"
else
printf "%b\nSomething went wrong, a source file is empty, exiting... \n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE" && exit 1
fi
################################################################################################################################################################
# Update translations and locale files
################################################################################################################################################################
[ -d ./translations ] && po_files=$(find translations/po-files/* -name "*.po" | tr ' ' '\n' | grep ".po$" | grep -v "source" | xargs)
[ -z "$po_files" ] && echo "Something went wrong, exiting..." && exit 1
for l in $po_files; do
locale=""
locale=$(echo "$l" | sed 's:.*/::; s/.po$//g')
printf "%b\n%b\n%b\n" "$DIVIDING_LINE" "$locale" "$DIVIDING_LINE"
[ -z "$locale" ] && echo "Something went wrong, exiting..." && exit 1
mkdir -p translations/usr/share/locale/"$locale"/LC_MESSAGES
msgmerge -U "$l" translations/source.pot
if [ ! -s "$l" ]; then
echo "WARNING, $l is empty, exiting..." && exit 1
else
msgfmt -o translations/usr/share/locale/"$locale"/LC_MESSAGES/am.mo "$l"
fi
done
rm -f translations/po-files/*~
printf "%b\nAll localizationfiles are updated\n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE"