commit | author | age
|
664710
|
1 |
#!/bin/sh |
AM |
2 |
|
|
3 |
# In 'translator' mode files will contain empty translated texts |
|
4 |
# where translation is not available, we'll remove these later |
|
5 |
|
a630ba
|
6 |
# Note: there's a bug in txclib, so if the command below doesn't |
AM |
7 |
# work see https://github.com/transifex/transifex-client/commit/a80320735973dd608b48520bf3b89ad53e2b088b |
|
8 |
|
63dd80
|
9 |
tx --debug pull -a -f --mode translator |
664710
|
10 |
|
AM |
11 |
PWD=`dirname "$0"` |
|
12 |
|
|
13 |
do_clean() |
|
14 |
{ |
915bac
|
15 |
# do not cleanup en_US files |
AM |
16 |
echo "$1" | grep -v en_US > /dev/null || return |
|
17 |
|
664710
|
18 |
echo "Cleaning $1" |
AM |
19 |
|
|
20 |
# remove untranslated/empty texts |
63dd80
|
21 |
perl -pi -e "s/^\\\$(labels|messages)\[[^]]+\]\s+=\s+'';\n//" $1 |
TB |
22 |
perl -pi -e "s/^\\\$(labels|messages)\[[^]]+\]\s+=\s+\"\";\n//" $1 |
6e0da1
|
23 |
# remove variable initialization |
AM |
24 |
perl -pi -e "s/^\\\$(labels|messages)\s*=\s*array\(\);\n//" $1 |
664710
|
25 |
# remove (one-line) comments |
6e0da1
|
26 |
perl -pi -e "s/^\\/\\/.*//" $1 |
664710
|
27 |
# remove empty lines (but not in file header) |
413617
|
28 |
perl -ne 'print if ($. < 18 || length($_) > 1)' $1 > $1.tmp |
664710
|
29 |
mv $1.tmp $1 |
AM |
30 |
} |
|
31 |
|
|
32 |
# clean up translation files |
|
33 |
for file in $PWD/../program/localization/*/*.inc; do |
|
34 |
do_clean $file |
|
35 |
done |
|
36 |
for file in $PWD/../plugins/*/localization/*.inc; do |
|
37 |
do_clean $file |
|
38 |
done |
8404fe
|
39 |
|
TB |
40 |
# remove empty localization files |
|
41 |
for file in $PWD/../program/localization/*/labels.inc; do grep -q -E '\$labels' $file || rm $file; done |
|
42 |
for file in $PWD/../program/localization/*/messages.inc; do grep -q -E '\$messages' $file || rm $file; done |
|
43 |
for file in $PWD/../plugins/*/localization/*.inc; do grep -q -E '\$(labels|messages)' $file || rm $file; done |
|
44 |
|