forked from revive-adserver/revive-adserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crowdin.sh
executable file
·43 lines (34 loc) · 1.02 KB
/
crowdin.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
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 <crowdin arguments>"
exit 1
fi
sed -i $'s/{\$\([^}]*\)}/{{\\1}}/g' lib/max/language/*/*.lang.php
crowdin-cli $*
sed -i $'s/{{\([^}]*\)}}/{$\\1}/g' lib/max/language/*/*.lang.php
# Fix extended printf
sed -i 's/\(%[0-9.]\+\)\\\\\$/\1\\$/g' lib/max/language/*/*.lang.php
# Remove empty translation strings from .lang.php files
sed -i '/^$.*= "";/d' lib/max/language/*/*.lang.php
sed -i "/^$.*= '';/d" lib/max/language/*/*.lang.php
# Remove empty translation files
for lang in `find lib/max/language -name '*.lang.php' `; do
n=`grep -c '^\\$.*=' $lang`
if [ $n -eq 0 ]; then
rm -f $lang
fi
done
# Compile plugin .mo files
for po in `find plugins_repo -name '*.po' `; do
n=`grep msgstr $po | grep -v 'msgstr ""' | wc -l`
if [ $n -eq 0 ]; then
rm -f $po
else
# Delete PO-Revision-Date that sometimes is changed when
# content hasn't
sed -i '/^"PO-Revision-Date/d' $po
# Generate .mo
mo=`echo "$po" | sed $'s/_lang.po/_lang/g' | sed $'s/po$/mo/g'`
msgfmt $po -o $mo
fi
done