mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
processing: enable translation for parameter descriptions
This commit is contained in:
parent
6564da037c
commit
9f1fcb72d4
@ -68,7 +68,7 @@ from osgeo import ogr
|
||||
|
||||
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 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
|
||||
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 @@ class Grass7Algorithm(QgsProcessingAlgorithm):
|
||||
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 @@ class OtbAlgorithm(QgsProcessingAlgorithm):
|
||||
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 @@ __copyright__ = '(C) 2018, Nyall Dawson'
|
||||
|
||||
__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 @@ class Parameters:
|
||||
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_FOLDER_DESTINATION = 'folderDestination'
|
||||
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 @@ for my $f (<python/plugins/processing/algs/grass*/description/*.txt>) {
|
||||
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 @@ for my $f (<python/plugins/processing/algs/grass*/description/*.txt>) {
|
||||
$strings{"GrassAlgorithm"}{$group} = 1;
|
||||
}
|
||||
|
||||
for my $f (<python/plugins/processing/algs/taudem/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;
|
||||
}
|
||||
|
||||
for my $f (<python/plugins/processing/algs/saga/description/*/*.txt>) {
|
||||
open I, $f;
|
||||
my $desc = scalar(<I>);
|
||||
|
||||
while( my($class, $name, $description, $rest) = split /\|/, scalar(<I>) ) {
|
||||
next unless defined $description;
|
||||
$description =~ s/\s+$//;
|
||||
$strings{"SAGAAlgorithm"}{$description} = 1
|
||||
}
|
||||
|
||||
close I;
|
||||
|
||||
chop $desc;
|
||||
|
Loading…
x
Reference in New Issue
Block a user