|
1 |
| -#!/bin/sh |
| 1 | +#!/bin/bash |
2 | 2 | # Update the translation files with strings used in QGIS
|
3 | 3 | # 1. create a clean Qt .pro file for the project
|
4 | 4 | # 2. run lupdate using the .pro file from step 1
|
|
7 | 7 | # name is reserved for the Windows qmake project file
|
8 | 8 | # update_ts_files.sh,v 1.3 2004/07/14 18:16:24 gsherman Exp
|
9 | 9 |
|
| 10 | +set -e |
| 11 | + |
10 | 12 | PATH=$QTDIR/bin:$PATH
|
11 | 13 |
|
12 | 14 | #first tar the qt_xx.ts files in i18n folder such that lupdate does not
|
13 | 15 | #merge the qgis strings to them
|
14 | 16 | echo Creating qt_ts.tar
|
15 |
| -tar -cvf i18n/qt_ts.tar i18n/qt_*.ts |
16 |
| -rm i18n/qt_*.ts |
| 17 | +tar --remove-files -cvf i18n/qt_ts.tar i18n/qt_*.ts |
| 18 | +exclude= |
| 19 | +opts= |
| 20 | +for i in "$@"; do |
| 21 | + if [ -f "i18n/qgis_$i.ts" ]; then |
| 22 | + exclude="$exclude --exclude i18n/qgis_$i.ts" |
| 23 | + else |
| 24 | + opts=" $i" |
| 25 | + fi |
| 26 | +done |
| 27 | +if [ -n "$exclude" ]; then |
| 28 | + tar --remove-files -cvf i18n/qgis_ts.tar i18n/qgis_*.ts$exclude |
| 29 | +fi |
| 30 | +echo Updating python translations |
| 31 | +cd python |
| 32 | +pylupdate4 utils.py -ts python-i18n.ts |
| 33 | +perl ../scripts/ts2cpp.pl python-i18n.ts python-i18n.cpp |
| 34 | +rm python-i18n.ts |
| 35 | +cd .. |
| 36 | +for i in python/plugins/*/CMakeLists.txt; do |
| 37 | + cd ${i%/*} |
| 38 | + pylupdate4 $(find . -name "*.py" -o -name "*.ui") -ts python-i18n.ts |
| 39 | + perl ../../../scripts/ts2cpp.pl python-i18n.ts python-i18n.cpp |
| 40 | + rm python-i18n.ts |
| 41 | + cd ../../.. |
| 42 | +done |
17 | 43 | echo Creating qmake project file
|
18 |
| -qmake -project -o qgis_ts.pro |
| 44 | +qmake -project -o qgis_ts.pro -nopwd src python i18n |
19 | 45 | echo Updating translation files
|
20 |
| -lupdate -verbose qgis_ts.pro |
| 46 | +lupdate$opts -verbose qgis_ts.pro |
| 47 | +echo Removing temporary python translation files |
| 48 | +perl -i.bak -ne 'print unless /^\s+<location.*python-i18n\.cpp.*$/;' i18n/qgis_*.ts |
| 49 | +rm python/python-i18n.cpp python/plugins/*/python-i18n.cpp i18n/qgis_*.ts.bak |
21 | 50 | echo Removing qmake project file
|
22 | 51 | rm qgis_ts.pro
|
23 | 52 | echo Unpacking qt_ts.tar
|
24 |
| -tar -xvf i18n/qt_ts.tar |
| 53 | +tar -xvf i18n/qt_ts.tar |
| 54 | +rm i18n/qt_ts.tar |
| 55 | +if [ -f i18n/qgis_ts.tar ]; then |
| 56 | + echo Unpacking i18n/qgis_ts.tar |
| 57 | + tar -xvf i18n/qgis_ts.tar |
| 58 | + rm i18n/qgis_ts.tar |
| 59 | +fi |
0 commit comments