@@ -9,13 +9,27 @@ gpg --allow-secret-key-import --import /gpg/nextcloud-bot.asc
99gpg --list-keys
1010
1111# fetch git repo
12- git clone git@github.com:$1 /$2 /app
12+ git clone git@github.com:$1 /$2 /app/default --depth 1
1313
14- if [ ! -f ' /app/.tx/config' ]; then
14+ cd default
15+
16+ if [ ! -f ' .tx/config' ]; then
1517 echo " Missing transifex configuration file .tx/config"
1618 exit 1
1719fi
1820
21+ # #################################
22+ # Migrate the transifex config to the new client version
23+ # #################################
24+ tx migrate
25+ git add --force .tx/config
26+ rm .tx/config_*
27+ git commit -am " fix(l10n): Update Transifex configuration" -s || true
28+ git push
29+
30+ # #################################
31+ # Validate sync setup
32+ # #################################
1933APP_ID=$( grep -oE ' <id>.*</id>' appinfo/info.xml | head --lines 1 | sed -E ' s/<id>(.*)<\/id>/\1/' )
2034IS_EX_APP=$( grep -q ' <external-app>' appinfo/info.xml && grep -q ' </external-app>' appinfo/info.xml && echo " true" || echo " false" )
2135RESOURCE_ID=$( grep -oE ' \[o:nextcloud:p:nextcloud:r:.*\]' .tx/config | sed -E ' s/\[o:nextcloud:p:nextcloud:r:(.*)\]/\1/' )
@@ -31,32 +45,36 @@ if [ "$RESOURCE_ID" = "talk_desktop" ]; then
3145 APP_ID=" talk_desktop"
3246fi
3347
34- # TODO use build/l10nParseAppInfo.php to fetch app names for l10n
35-
3648versions=' main master stable31 stable30'
37- if [ -f ' /app/ .tx/backport' ]; then
38- versions=" main master $( cat /app/ .tx/backport) "
49+ if [ -f ' .tx/backport' ]; then
50+ versions=" main master $( cat .tx/backport) "
3951fi
4052
41- # build POT files for all versions
4253mkdir stable-templates
54+ mkdir -p translationfiles/templates/
55+
56+ # #################################
57+ # Clone backport branches
58+ # #################################
59+ # Don't fail on checking out non existing branches
60+ set +e
61+ for version in $versions
62+ do
63+ git clone git@github.com:$1 /$2 /app/$version --depth 1 --branch $version
64+ done
65+ set -e
66+
67+ # #################################
68+ # Build POT files for all versions
69+ # #################################
4370for version in $versions
4471do
45- # skip if the branch doesn't exist
46- if git branch -r | egrep " ^\W*origin/$version $" ; then
47- echo " Valid branch: $version "
48- else
49- echo " Invalid branch: $version "
72+ if [ ! -d /app/$version ]; then
73+ # skip if the branch doesn't exist
5074 continue
5175 fi
52- git checkout $version
5376
54- # Migrate the transifex config to the new client version
55- tx migrate
56- git add --force .tx/config
57- rm .tx/config_*
58- git commit -am " fix(l10n): Update Transifex configuration" -s || true
59- git push
77+ cd /app/$version
6078
6179 # build POT files
6280 /translationtool.phar create-pot-files
6583 for file in $( ls)
6684 do
6785 FILE_SAVE_VERSION=$( echo $version | sed -E ' s/\//-/' )
68- mv $file ../.. /stable-templates/$FILE_SAVE_VERSION .$RESOURCE_ID .pot
86+ mv $file /app/default /stable-templates/$FILE_SAVE_VERSION .$RESOURCE_ID .pot
6987 done
7088 cd ../..
7189done
7290
91+
92+ # #################################
93+ # Sync with transifex
94+ # #################################
95+ cd /app/default
96+
7397# merge POT files into one
7498for file in $( ls stable-templates/master.* )
7599do
@@ -92,6 +116,9 @@ tx push -s
92116# pull translations - force pull because a fresh clone has newer time stamps
93117tx pull -f -a --minimum-perc=5
94118
119+ # delete removed l10n files that are used for language detection (they will be recreated during the write)
120+ rm -f l10n/* .js l10n/* .json
121+
95122# Copy back the po files from transifex resource id to app id
96123if [ " $RESOURCE_ID " = " $APP_ID " ] ; then
97124 echo ' App id and transifex resource id are the same, not renaming po files …'
@@ -112,34 +139,33 @@ else
112139 done
113140fi
114141
142+ # build JS/JSON based on translations
143+ /translationtool.phar convert-po-files
144+
145+ # #################################
146+ # Add translations to branches again
147+ # #################################
115148for version in $versions
116149do
117- # skip if the branch doesn't exist
118- if git branch -r | egrep " ^\W*origin/$version $" ; then
119- echo " Valid branch"
120- else
121- echo " Invalid branch"
150+ if [ ! -d /app/$version ]; then
151+ # skip if the branch doesn't exist
122152 continue
123153 fi
124- git checkout $version
154+
155+ cd /app/$version
125156
126157 # delete removed l10n files that are used for language detection (they will be recreated during the write)
127158 rm -f l10n/* .js l10n/* .json
128159
129- # build JS/JSON based on translations
130- /translationtool.phar convert-po-files
131-
132- if [ -d tests ]; then
133- # remove tests/
134- rm -rf tests
135- git checkout -- tests/
136- fi
160+ # Copy JS and JSON
161+ cp /app/default/l10n/* .js /app/default/l10n/* .json l10n
137162
138163 # create git commit and push it
139164 git add l10n/* .js l10n/* .json
140165
141166 # for ExApps, we need to include .po translation files as well
142167 if [ " $IS_EX_APP " = " true" ]; then
168+ cp /app/default/translationfiles/* .po translationfiles
143169 git add translationfiles/* .po
144170 fi
145171
152178# End of verbose mode
153179set +xe
154180
155- /validateTranslationFiles.sh
181+ # #################################
182+ # Validate translations
183+ # #################################
184+ /validateTranslationFiles.sh /app/default
156185exit $?
0 commit comments