Skip to content

Commit 6ed389c

Browse files
committed
fix translation string again and improve translation scripts (followup 79a095c)
1 parent 4497c03 commit 6ed389c

File tree

5 files changed

+41
-26
lines changed

5 files changed

+41
-26
lines changed

python/console/console_compile_apis.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def _preparationFinished(self):
6161
os.remove(self._pap_file)
6262
self.ui.label.setText(QCoreApplication.translate("PythonConsole", "Saving prepared file..."))
6363
prepd = self._api.savePrepared(self._pap_file)
64-
rslt = self.trUtf8("Error")
64+
rslt = self.tr("Error")
6565
if prepd:
6666
rslt = QCoreApplication.translate("PythonConsole", "Saved")
6767
self.ui.label.setText(u'{0} {1}'.format(self.ui.label.text(), rslt))
@@ -88,6 +88,5 @@ def prepareAPI(self):
8888
self.ui.progressBar.setVisible(False)
8989
self.ui.plainTextEdit.setVisible(True)
9090
self.ui.plainTextEdit.insertPlainText(err)
91-
self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText(
92-
self.trUtf8("Done"))
91+
self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Done"))
9392
self.adjustSize()

python/plugins/processing/algs/gdal/GdalAlgorithmDialog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28+
from qgis.PyQt.QtCore import QCoreApplication
2829
from qgis.PyQt.QtWidgets import (QWidget,
2930
QVBoxLayout,
3031
QPushButton,
@@ -58,7 +59,7 @@ def __init__(self, alg):
5859

5960
self.setMainWidget(GdalParametersPanel(self, alg))
6061

61-
self.runAsBatchButton = QPushButton(self.tr("Run as Batch Process…"))
62+
self.runAsBatchButton = QPushButton(QCoreApplication.translate("AlgorithmDialog", "Run as Batch Process…"))
6263
self.runAsBatchButton.clicked.connect(self.runAsBatch)
6364
self.buttonBox.addButton(self.runAsBatchButton, QDialogButtonBox.ResetRole) # reset role to ensure left alignment
6465

python/plugins/processing/gui/AlgorithmDialog.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@
2929
from pprint import pformat
3030
import time
3131

32-
from qgis.PyQt.QtCore import Qt
33-
from qgis.PyQt.QtWidgets import QMessageBox, QApplication, QPushButton, QWidget, QVBoxLayout, QSizePolicy, QDialogButtonBox
34-
from qgis.PyQt.QtGui import QCursor, QColor, QPalette
32+
from qgis.PyQt.QtCore import QCoreApplication
33+
from qgis.PyQt.QtWidgets import QMessageBox, QPushButton, QSizePolicy, QDialogButtonBox
34+
from qgis.PyQt.QtGui import QColor, QPalette
3535

3636
from qgis.core import (QgsProject,
3737
QgsApplication,
3838
QgsProcessingUtils,
39-
QgsMessageLog,
4039
QgsProcessingParameterDefinition,
41-
QgsProcessingOutputRasterLayer,
42-
QgsProcessingOutputVectorLayer,
4340
QgsProcessingAlgRunnerTask,
4441
QgsProcessingOutputHtml,
4542
QgsProcessingParameterVectorDestination,
@@ -56,16 +53,13 @@
5653
from processing.gui.ParametersPanel import ParametersPanel
5754
from processing.gui.BatchAlgorithmDialog import BatchAlgorithmDialog
5855
from processing.gui.AlgorithmDialogBase import AlgorithmDialogBase
59-
from processing.gui.AlgorithmExecutor import execute, executeIterating
56+
from processing.gui.AlgorithmExecutor import executeIterating
6057
from processing.gui.Postprocessing import handleAlgorithmResults
6158

6259
from processing.core.parameters import ParameterRaster
6360
from processing.core.parameters import ParameterVector
6461
from processing.core.parameters import ParameterExtent
6562
from processing.core.parameters import ParameterMultipleInput
66-
from processing.core.GeoAlgorithm import executeAlgorithm
67-
68-
from processing.core.outputs import OutputTable
6963

7064
from processing.tools import dataobjects
7165

@@ -83,7 +77,7 @@ def __init__(self, alg):
8377
self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
8478
self.layout().insertWidget(0, self.bar)
8579

86-
self.runAsBatchButton = QPushButton(self.tr("Run as Batch Process…"))
80+
self.runAsBatchButton = QPushButton(QCoreTranslation.translate("AlgorithmDialog", "Run as Batch Process…"))
8781
self.runAsBatchButton.clicked.connect(self.runAsBatch)
8882
self.buttonBox.addButton(self.runAsBatchButton, QDialogButtonBox.ResetRole) # reset role to ensure left alignment
8983

@@ -179,7 +173,7 @@ def accept(self):
179173
if reply == QMessageBox.No:
180174
return
181175
checkExtentCRS = ProcessingConfig.getSetting(ProcessingConfig.WARN_UNMATCHING_EXTENT_CRS)
182-
#TODO
176+
# TODO
183177
if False and checkExtentCRS and self.checkExtentCRS():
184178
reply = QMessageBox.question(self, self.tr("Extent CRS"),
185179
self.tr('Extent parameters must use the same CRS as the input layers.\n'

scripts/processing2cpp.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
die "usage: $0 dest.cpp\n" unless @ARGV==1;
2121

2222
open F, ">$ARGV[0]";
23+
binmode(F, ":utf8");
2324

2425
print F <<EOF;
2526
/*

scripts/update_ts.sh

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616

1717
set -e
1818

19-
case "$1" in
19+
action=$1
20+
21+
case "$action" in
2022
pull|push|update)
2123
;;
2224

2325
*)
24-
echo "usage: $(basename $0) {pull|{push|update} builddirectory}"
26+
echo "usage: $(basename $0) {pull|{push|update} builddirectory [lang...]}"
2527
exit 1
2628
esac
2729

@@ -72,41 +74,59 @@ if ! type tx >/dev/null 2>&1; then
7274
exit 1
7375
fi
7476

77+
files=
7578
if [ -d "$2" ]; then
7679
builddir=$(realpath $2)
7780
textcpp=
7881
for i in $builddir/src/core/qgsexpression_texts.cpp $builddir/src/core/qgscontexthelp_texts.cpp; do
7982
if [ -f $i ]; then
8083
textcpp="$textcpp $i"
81-
elif [ "$1" != "pull" ]; then
84+
elif [ "$action" != "pull" ]; then
8285
echo Generated help file $i not found
8386
exit 1
8487
fi
8588
done
86-
elif [ "$1" != "pull" ]; then
89+
shift
90+
shift
91+
for t in i18n/qgis_*.ts; do
92+
for l in "$@"; do
93+
if [ "i18n/qgis_$l.ts" = "$t" ]; then
94+
continue 2
95+
fi
96+
done
97+
files="$files $t"
98+
done
99+
100+
elif [ "$action" != "pull" ]; then
87101
echo Build directory not found
88102
exit 1
89103
fi
90104

91105
trap cleanup EXIT
92106

93107
echo Saving translations
94-
files="$(find python -name "*.ts") src/plugins/plugin_template/plugingui.cpp src/plugins/plugin_template/plugin.cpp"
95-
[ $1 = push ] && files="$files i18n/qgis_*.ts"
108+
files="$files $(find python -name "*.ts") src/plugins/plugin_template/plugingui.cpp src/plugins/plugin_template/plugin.cpp"
109+
[ $action = push ] && files="$files i18n/qgis_*.ts"
96110
tar --remove-files -cf i18n/backup.tar $files
97111

98-
if [ $1 = push ]; then
112+
if [ $action = push ]; then
99113
echo Pulling source from transifex...
100114
tx pull -s -l none
101115
if ! [ -f "i18n/qgis_en.ts" ]; then
102116
echo Download of source translation failed
103117
exit
104118
fi
105-
elif [ $1 = pull ]; then
119+
elif [ $action = pull ]; then
106120
rm i18n/qgis_*.ts
107121

108122
echo Pulling new translations...
109-
tx pull -a -s --minimum-perc=35
123+
shift
124+
if [ "$#" -gt 0 ]; then
125+
o="-l $@"
126+
else
127+
o="-a"
128+
fi
129+
tx pull $o -s --minimum-perc=35
110130
fi
111131

112132
echo Updating python translations
@@ -147,7 +167,7 @@ $LUPDATE -locations absolute -verbose qgis_ts.pro
147167

148168
perl -i.bak -ne 'print unless /^\s+<location.*qgs(expression|contexthelp)_texts\.cpp.*$/;' i18n/qgis_*.ts
149169

150-
if [ $1 = push ]; then
170+
if [ $action = push ]; then
151171
echo Pushing translation...
152172
tx push -s
153173
else

0 commit comments

Comments
 (0)