blob: 2948638101e3fbbb3acd451d52494e7bd4ba5d31 (
plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#!/bin/sh
# verbose and exit on error
set -xe
# import GPG keys
gpg --import /gpg/nextcloud-bot.public.asc
gpg --allow-secret-key-import --import /gpg/nextcloud-bot.asc
gpg --list-keys
# fetch git repo
git clone git@github.com:$1/$2 /app
if [ ! -f '/app/.tx/config' ]; then
echo "Missing transifex configuration file .tx/config"
exit 1
fi
APP_ID=$(grep -oE '<id>.*</id>' appinfo/info.xml | head --lines 1 | sed -E 's/<id>(.*)<\/id>/\1/')
RESOURCE_ID=$(grep -oE '\[o:nextcloud:p:nextcloud:r:.*\]' .tx/config | sed -E 's/\[o:nextcloud:p:nextcloud:r:(.*)\]/\1/')
SOURCE_FILE=$(grep -oE '^source_file\s*=\s*(.+)$' .tx/config | sed -E 's/source_file\s*=\s*(.+)/\1/')
if [ "$RESOURCE_ID" = "MYAPP" ]; then
echo "Invalid transifex configuration file .tx/config (translating MYAPP instead of real value)"
exit 2
fi
# TODO use build/l10nParseAppInfo.php to fetch app names for l10n
versions='stable23 stable24 stable25 master main'
if [ -f '/app/.tx/backport' ]; then
versions="$(cat /app/.tx/backport) master main"
fi
# build POT files for all versions
mkdir stable-templates
for version in $versions
do
# skip if the branch doesn't exist
if git branch -r | egrep "^\W*origin/$version$" ; then
echo "Valid branch"
else
echo "Invalid branch"
continue
fi
git checkout $version
# Migrate the transifex config to the new client version
tx migrate
git add --force .tx/config
rm .tx/config_*
git commit -am "[tx-robot] Update transifex configuration" -s || true
git push
# ignore build folder logreader
if [ "$version" = "stable23" ] ; then
if [ "$2" = "logreader" ] ; then
rm -rf build
fi
fi
# build POT files
/translationtool.phar create-pot-files
# ignore build folder logreader
if [ "$version" = "stable23" ] ; then
if [ "$2" = "logreader" ] ; then
git checkout -- build
fi
fi
cd translationfiles/templates/
for file in $(ls)
do
FILE_SAVE_VERSION=$(echo $version | sed -E 's/\//-/')
mv $file ../../stable-templates/$FILE_SAVE_VERSION.$RESOURCE_ID.pot
done
cd ../..
done
# merge POT files into one
for file in $(ls stable-templates/master.*)
do
name=$(echo $file | cut -b 25- )
msgcat --use-first stable-templates/*.$name > $SOURCE_FILE
done
# alternative merge of main branch
for file in $(ls stable-templates/main.*)
do
name=$(echo $file | cut -b 23- )
msgcat --use-first stable-templates/*.$name > $SOURCE_FILE
done
# remove intermediate POT files
rm -rf stable-templates
# push sources
tx push -s
# pull translations - force pull because a fresh clone has newer time stamps
tx pull -f -a --minimum-perc=5
# Copy back the po files from transifex resource id to app id
if [ "$RESOURCE_ID" = "$APP_ID" ] ; then
echo 'App id and transifex resource id are the same, not renaming po files …'
else
echo "App id [$APP_ID] and transifex resource id [$RESOURCE_ID] mismatch"
echo 'Renaming po files …'
for file in $(ls translationfiles)
do
if [ "$file" = 'templates' ]; then
continue;
fi
# Some special handling for apps where the resource name is reserved by transifex (transfer, analytics, ...)
# in that case the downloaded ".po" files already have the correct name, so we skip the renaming.
if [ -f translationfiles/$file/$RESOURCE_ID.po ]; then
mv translationfiles/$file/$RESOURCE_ID.po translationfiles/$file/$APP_ID.po
fi
done
fi
# reverse version list to apply backports
backportVersions=$(echo $versions | awk '{for(i=NF;i>=1;i--) printf "%s ", $i;print ""}')
for version in $backportVersions
do
# skip if the branch doesn't exist
if git branch -r | egrep "^\W*origin/$version$" ; then
echo "Valid branch"
else
echo "Invalid branch"
continue
fi
git checkout $version
# delete removed l10n files that are used for language detection (they will be recreated during the write)
rm -f l10n/*.js l10n/*.json
# build JS/JSON based on translations
/translationtool.phar convert-po-files
if [ -d tests ]; then
# remove tests/
rm -rf tests
git checkout -- tests/
fi
# create git commit and push it
git add l10n/*.js l10n/*.json
git commit -am "[tx-robot] updated from transifex" -s || true
git push origin $version
echo "done with $version"
done
|