Skip to content

Commit 5dd2f51

Browse files
committedNov 24, 2014
translation script update:
* TRANSLATORS stats also needs lupdate run * support numerus forms in python translation strings
1 parent af3418a commit 5dd2f51

File tree

4 files changed

+125
-157
lines changed

4 files changed

+125
-157
lines changed
 

‎scripts/pull_ts.sh

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,4 @@
1515
###########################################################################
1616

1717
# Pull the translations from transifex and update TRANSLATORS
18-
19-
set -e
20-
21-
cleanup() {
22-
if [ -f i18n/python_ts.tar ]; then
23-
tar -xf i18n/python_ts.tar
24-
fi
25-
if [ -f i18n/qgis_ts.tar ]; then
26-
echo Restoring excluded translations
27-
tar -xf i18n/qgis_ts.tar
28-
fi
29-
30-
echo Removing temporary files
31-
perl -i.bak -ne 'print unless /^\s+<location.*python-i18n\.cpp.*$/;' i18n/qgis_*.ts
32-
for i in \
33-
python/python-i18n.{ts,cpp} \
34-
python/plugins/*/python-i18n.{ts,cpp} \
35-
i18n/qgis_*.ts.bak \
36-
src/plugins/grass/grasslabels-i18n.cpp \
37-
i18n/qgis_ts.tar \
38-
i18n/python_ts.tar \
39-
qgis_ts.pro
40-
do
41-
[ -f "$i" ] && rm "$i"
42-
done
43-
44-
for i in \
45-
src/plugins/plugin_template/plugingui.cpp \
46-
src/plugins/plugin_template/plugin.cpp
47-
do
48-
[ -f "$i.save" ] && mv "$i.save" "$i"
49-
done
50-
51-
trap "" EXIT
52-
}
53-
54-
PATH=$QTDIR/bin:$PATH
55-
56-
if ! type tx >/dev/null 2>&1; then
57-
echo "tx not found"
58-
exit 1
59-
fi
60-
61-
if ! type lrelease >/dev/null 2>&1; then
62-
echo "lrelease not found"
63-
exit 1
64-
fi
65-
66-
trap cleanup EXIT
67-
68-
tar --remove-files -cf i18n/python_ts.tar $(find python -name "*.ts")
69-
70-
echo Saving translations
71-
tar --remove-files -cf i18n/qgis_ts.tar i18n/qgis_*.ts
72-
73-
tx pull -a -s
74-
75-
echo Updating TRANSLATORS File
76-
./scripts/tsstat.pl >doc/TRANSLATORS
18+
scripts/update_ts.sh pull

‎scripts/push_ts.sh

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -15,101 +15,4 @@
1515
###########################################################################
1616

1717
# Update the english translation and push it to transifex
18-
19-
set -e
20-
21-
cleanup() {
22-
if [ -f i18n/python_ts.tar ]; then
23-
tar -xf i18n/python_ts.tar
24-
fi
25-
if [ -f i18n/qgis_ts.tar ]; then
26-
echo Restoring excluded translations
27-
tar -xf i18n/qgis_ts.tar
28-
fi
29-
30-
echo Removing temporary files
31-
perl -i.bak -ne 'print unless /^\s+<location.*python-i18n\.cpp.*$/;' i18n/qgis_*.ts
32-
for i in \
33-
python/python-i18n.{ts,cpp} \
34-
python/plugins/*/python-i18n.{ts,cpp} \
35-
i18n/qgis_*.ts.bak \
36-
src/plugins/grass/grasslabels-i18n.cpp \
37-
i18n/qgis_ts.tar \
38-
i18n/python_ts.tar \
39-
qgis_ts.pro
40-
do
41-
[ -f "$i" ] && rm "$i"
42-
done
43-
44-
for i in \
45-
src/plugins/plugin_template/plugingui.cpp \
46-
src/plugins/plugin_template/plugin.cpp
47-
do
48-
[ -f "$i.save" ] && mv "$i.save" "$i"
49-
done
50-
51-
trap "" EXIT
52-
}
53-
54-
PATH=$QTDIR/bin:$PATH
55-
56-
if type qmake-qt4 >/dev/null 2>&1; then
57-
QMAKE=qmake-qt4
58-
else
59-
QMAKE=qmake
60-
fi
61-
62-
if ! type pylupdate4 >/dev/null 2>&1; then
63-
echo "pylupdate4 not found"
64-
exit 1
65-
fi
66-
67-
if ! type tx >/dev/null 2>&1; then
68-
echo "tx not found"
69-
exit 1
70-
fi
71-
72-
if type lupdate-qt4 >/dev/null 2>&1; then
73-
LUPDATE=lupdate-qt4
74-
else
75-
LUPDATE=lupdate
76-
fi
77-
78-
trap cleanup EXIT
79-
80-
tar --remove-files -cf i18n/python_ts.tar $(find python -name "*.ts")
81-
echo Saving translations
82-
tar --remove-files -cf i18n/qgis_ts.tar i18n/qgis_*.ts
83-
84-
echo Pulling source from transifex...
85-
tx pull -s
86-
87-
echo Updating python translations
88-
cd python
89-
pylupdate4 utils.py {console,pyplugin_installer}/*.{py,ui} -ts python-i18n.ts
90-
perl ../scripts/ts2cpp.pl python-i18n.ts python-i18n.cpp
91-
rm python-i18n.ts
92-
cd ..
93-
for i in python/plugins/*/CMakeLists.txt; do
94-
cd ${i%/*}
95-
pylupdate4 $(find . -name "*.py" -o -name "*.ui") -ts python-i18n.ts
96-
perl ../../../scripts/ts2cpp.pl python-i18n.ts python-i18n.cpp
97-
rm python-i18n.ts
98-
cd ../../..
99-
done
100-
echo Updating GRASS module translations
101-
perl scripts/qgm2cpp.pl >src/plugins/grass/grasslabels-i18n.cpp
102-
mv src/plugins/plugin_template/plugingui.cpp src/plugins/plugin_template/plugingui.cpp.save
103-
echo Creating qmake project file
104-
for i in \
105-
src/plugins/plugin_template/plugingui.cpp \
106-
src/plugins/plugin_template/plugin.cpp
107-
do
108-
[ -f "$i" ] && mv "$i" "$i.save"
109-
done
110-
$QMAKE -project -o qgis_ts.pro -nopwd src python i18n
111-
112-
echo Updating translations
113-
$LUPDATE -locations none -verbose qgis_ts.pro
114-
115-
tx push -s
18+
scripts/update_ts.sh push

‎scripts/ts2cpp.pl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
print F ",\"$context->{comment}->[0]\"";
5050
}
5151

52+
if( exists $message->{numerus} && $message->{numerus} eq "yes" ) {
53+
print '"",' unless exists $message->{comment} && $message->{comment}->[0] ne "";
54+
print F ",1"
55+
}
56+
5257
print F ");\n";
5358
}
5459
}

‎scripts/update_ts.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
###########################################################################
3+
# update_ts.sh
4+
# ---------------------
5+
# Date : November 2014
6+
# Copyright : (C) 2014 by Juergen E. Fischer
7+
# Email : jef at norbit dot de
8+
###########################################################################
9+
# #
10+
# This program is free software; you can redistribute it and/or modify #
11+
# it under the terms of the GNU General Public License as published by #
12+
# the Free Software Foundation; either version 2 of the License, or #
13+
# (at your option) any later version. #
14+
# #
15+
###########################################################################
16+
17+
set -e
18+
19+
case "$1" in
20+
pull|push)
21+
;;
22+
23+
*)
24+
echo "usage: $(basename $0) {push|pull}"
25+
exit 1
26+
esac
27+
28+
cleanup() {
29+
if [ -f i18n/backup.tar ]; then
30+
echo Restoring files...
31+
tar -xf i18n/backup.tar
32+
fi
33+
34+
echo Removing temporary files
35+
for i in \
36+
python/python-i18n.{ts,cpp} \
37+
python/plugins/*/python-i18n.{ts,cpp} \
38+
src/plugins/grass/grasslabels-i18n.cpp \
39+
i18n/backup.tar \
40+
qgis_ts.pro
41+
do
42+
[ -f "$i" ] && rm "$i"
43+
done
44+
45+
trap "" EXIT
46+
}
47+
48+
PATH=$QTDIR/bin:$PATH
49+
50+
if type qmake-qt4 >/dev/null 2>&1; then
51+
QMAKE=qmake-qt4
52+
else
53+
QMAKE=qmake
54+
fi
55+
56+
if ! type pylupdate4 >/dev/null 2>&1; then
57+
echo "pylupdate4 not found"
58+
exit 1
59+
fi
60+
61+
if type lupdate-qt4 >/dev/null 2>&1; then
62+
LUPDATE=lupdate-qt4
63+
else
64+
LUPDATE=lupdate
65+
fi
66+
67+
if ! type tx >/dev/null 2>&1; then
68+
echo "tx not found"
69+
exit 1
70+
fi
71+
72+
trap cleanup EXIT
73+
74+
echo Saving translations
75+
files="$(find python -name "*.ts") src/plugins/plugin_template/plugingui.cpp src/plugins/plugin_template/plugin.cpp"
76+
[ $1 = push ] && files="$files i18n/qgis_*.ts"
77+
tar --remove-files -cf i18n/backup.tar $files
78+
79+
if [ $1 = push ]; then
80+
echo Pulling source from transifex...
81+
tx pull -s -l none
82+
else
83+
rm i18n/qgis_*.ts
84+
85+
echo Pulling new translations...
86+
tx pull -a -s --minimum-perc=35
87+
fi
88+
89+
echo Updating python translations
90+
cd python
91+
pylupdate4 utils.py {console,pyplugin_installer}/*.{py,ui} -ts python-i18n.ts
92+
perl ../scripts/ts2cpp.pl python-i18n.ts python-i18n.cpp
93+
rm python-i18n.ts
94+
cd ..
95+
for i in python/plugins/*/CMakeLists.txt; do
96+
cd ${i%/*}
97+
pylupdate4 $(find . -name "*.py" -o -name "*.ui") -ts python-i18n.ts
98+
perl ../../../scripts/ts2cpp.pl python-i18n.ts python-i18n.cpp
99+
rm python-i18n.ts
100+
cd ../../..
101+
done
102+
103+
echo Updating GRASS module translations
104+
perl scripts/qgm2cpp.pl >src/plugins/grass/grasslabels-i18n.cpp
105+
106+
echo Creating qmake project file
107+
$QMAKE -project -o qgis_ts.pro -nopwd src python i18n
108+
109+
echo Updating translations
110+
$LUPDATE -locations none -verbose qgis_ts.pro
111+
112+
if [ $1 = push ]; then
113+
echo Pushing translation...
114+
tx push -s
115+
else
116+
echo Updating TRANSLATORS File
117+
./scripts/tsstat.pl >doc/TRANSLATORS
118+
fi

0 commit comments

Comments
 (0)
Please sign in to comment.