Skip to content
Permalink
Browse files

processing: enable translation for parameter descriptions

  • Loading branch information
jef-n committed Mar 4, 2019
1 parent 6564da0 commit 9f1fcb72d40a7f5ad5633912017651cb088ca9f4
@@ -68,7 +68,7 @@

from processing.core.ProcessingConfig import ProcessingConfig

from processing.core.parameters import (getParameterFromString)
from processing.core.parameters import getParameterFromString

from .Grass7Utils import Grass7Utils

@@ -203,6 +203,7 @@ def defineCharacteristicsFromFile(self):
self._name = self.grass7Name
else:
self._name = line[:line.find(' ')].lower()
self._short_description = QCoreApplication.translate("GrassAlgorithm", line)
self._display_name = self._name
# Read the grass group
line = lines.readline().strip('\n').strip()
@@ -219,7 +220,7 @@ def defineCharacteristicsFromFile(self):
line = line.strip('\n').strip()
if line.startswith('Hardcoded'):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
parameter = getParameterFromString(line)
parameter = getParameterFromString(line, "GrassAlgorithm")
if parameter is not None:
self.params.append(parameter)
if isinstance(parameter, (QgsProcessingParameterVectorLayer, QgsProcessingParameterFeatureSource)):
@@ -182,7 +182,7 @@ def verifyRasterNum(alg, parameters, context, rasters, mini, maxi=None):
# alg.removeOutputFromName(output)

# # Create output parameter
# param = getParameterFromString("ParameterString|{}|output file|None|False|False".format(output))
# param = getParameterFromString("ParameterString|{}|output file|None|False|False".format(output), 'GrassAlgorithm')
# param.value = outputFile.value
# alg.addParameter(param)

@@ -135,7 +135,7 @@ def defineCharacteristicsFromFile(self):
options = params[2].split(';')
param = OtbParameterChoice(params[0], params[1], options, params[3], params[4])
else:
param = getParameterFromString(line)
param = getParameterFromString(line, 'OtbAlgorithm')

#if parameter is None, then move to next line and continue
if param is None:
@@ -26,8 +26,7 @@

__revision__ = '$Format:%H$'

import os
import importlib
from qgis.PyQt.QtCore import QCoreApplication
from qgis.core import QgsProcessingParameterRasterDestination
from processing.core.parameters import getParameterFromString

@@ -70,6 +69,7 @@ def create_parameter_from_line(line):
params[3] = True if params[3].lower() == 'true' else False
if len(params) > 4:
params[4] = True if params[4].lower() == 'true' else False
return SagaImageOutputParam(*params)
param = SagaImageOutputParam(*params)
param.setDescription(QCoreApplication.translate("SAGAAlgorithm", param.description()))
else:
return getParameterFromString(line)
return getParameterFromString(line, "SAGAAlgorithm")
@@ -89,7 +89,7 @@
PARAMETER_RASTER_DESTINATION = 'rasterDestination'


def getParameterFromString(s):
def getParameterFromString(s, context):
# Try the parameter definitions used in description files
if '|' in s and (s.startswith("QgsProcessingParameter") or s.startswith("*QgsProcessingParameter") or s.startswith('Parameter') or s.startswith('*Parameter')):
isAdvanced = False
@@ -244,6 +244,8 @@ def getParameterFromString(s):
if isAdvanced:
param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)

param.setDescription(QCoreApplication.translate(context, param.description()))

return param
else:
return None
@@ -48,6 +48,13 @@ sub xmlescape {
my $name = scalar(<I>);
my $desc = scalar(<I>);
my $group = scalar(<I>);

while( my($class, $name, $description, $rest) = split /\|/, scalar(<I>) ) {
next unless defined $description;
$description =~ s/\s+$//;
$strings{"GrassAlgorithm"}{$description} = 1
}

close I;

chop $desc;
@@ -57,23 +64,16 @@ sub xmlescape {
$strings{"GrassAlgorithm"}{$group} = 1;
}

for my $f (<python/plugins/processing/algs/taudem/description/*/*.txt>) {
for my $f (<python/plugins/processing/algs/saga/description/*/*.txt>) {
open I, $f;
my $desc = scalar(<I>);
my $name = scalar(<I>);
my $group = scalar(<I>);
close I;

chop $desc;
chop $group;

$strings{"TAUDEMAlgorithm"}{$desc} = 1;
$strings{"TAUDEMAlgorithm"}{$group} = 1;
}
while( my($class, $name, $description, $rest) = split /\|/, scalar(<I>) ) {
next unless defined $description;
$description =~ s/\s+$//;
$strings{"SAGAAlgorithm"}{$description} = 1
}

for my $f (<python/plugins/processing/algs/saga/description/*/*.txt>) {
open I, $f;
my $desc = scalar(<I>);
close I;

chop $desc;

0 comments on commit 9f1fcb7

Please sign in to comment.
You can’t perform that action at this time.