Skip to content

Commit

Permalink
Python - Use some format function for translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Apr 25, 2023
1 parent 01e7a71 commit 9e8364a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/gdal/ogr2ogr.py
Expand Up @@ -87,7 +87,7 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
output, outputFormat = GdalUtils.ogrConnectionStringAndFormat(outFile, context)

if outputFormat in ('SQLite', 'GPKG') and os.path.isfile(output):
raise QgsProcessingException(self.tr(f'Output file "{output}" already exists.'))
raise QgsProcessingException(self.tr('Output file "{}" already exists.').format(output))

arguments = []
if outputFormat:
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/qgis/IdwInterpolation.py
Expand Up @@ -136,7 +136,8 @@ def processAlgorithm(self, parameters, context, feedback):
data.valueSource = int(v[1])
data.interpolationAttribute = int(v[2])
if data.valueSource == QgsInterpolator.ValueAttribute and data.interpolationAttribute == -1:
raise QgsProcessingException(self.tr(f'Layer {i + 1} is set to use a value attribute, but no attribute was set'))
raise QgsProcessingException(self.tr(
'Layer {} is set to use a value attribute, but no attribute was set').format(i + 1))

if v[3] == '0':
data.sourceType = QgsInterpolator.SourcePoints
Expand Down
Expand Up @@ -122,7 +122,8 @@ def processAlgorithm(self, parameters, context, feedback):
selValue = value if method != 1 else int(round(value * len(subset), 0))
if selValue > len(subset):
selValue = len(subset)
feedback.reportError(self.tr(f'Subset "{k}" is smaller than requested number of features.'))
feedback.reportError(self.tr(
'Subset "{}" is smaller than requested number of features.').format(k))
selran.extend(random.sample(subset, selValue))

total = 100.0 / featureCount if featureCount else 1
Expand Down
Expand Up @@ -193,7 +193,7 @@ def processAlgorithm(self, parameters, context, feedback):
pointCount = int(round(this_value * da.measureArea(fGeom)))

if pointCount == 0:
feedback.pushInfo(f"Skip feature {f.id()} as number of points for it is 0.")
feedback.pushInfo(self.tr("Skip feature {} as number of points for it is 0.").format(f.id()))
continue

index = None
Expand Down
Expand Up @@ -133,7 +133,7 @@ def processAlgorithm(self, parameters, context, feedback):
selValue = value if method != 1 else int(round(value * len(subset), 0))
if selValue > len(subset):
selValue = len(subset)
feedback.reportError(self.tr(f'Subset "{k}" is smaller than requested number of features.'))
feedback.reportError(self.tr('Subset "{}" is smaller than requested number of features.').format(k))
selran.extend(random.sample(subset, selValue))

layer.selectByIds(selran)
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/qgis/TinInterpolation.py
Expand Up @@ -155,7 +155,8 @@ def processAlgorithm(self, parameters, context, feedback):
data.valueSource = int(v[1])
data.interpolationAttribute = int(v[2])
if data.valueSource == QgsInterpolator.ValueAttribute and data.interpolationAttribute == -1:
raise QgsProcessingException(self.tr(f'Layer {i + 1} is set to use a value attribute, but no attribute was set'))
raise QgsProcessingException(self.tr(
'Layer {} is set to use a value attribute, but no attribute was set').format(i + 1))

if v[3] == '0':
data.sourceType = QgsInterpolator.SourcePoints
Expand Down
Expand Up @@ -238,7 +238,7 @@ def accept(self):

paramTypeDef = QgsApplication.instance().processingRegistry().parameterType(typeId)
if not paramTypeDef:
msg = self.tr(f'The parameter `{typeId}` is not registered, are you missing a required plugin?')
msg = self.tr('The parameter `{}` is not registered, are you missing a required plugin?').format(typeId)
raise UndefinedParameterException(msg)
self.param = paramTypeDef.create(name)
self.param.setDescription(description)
Expand Down

0 comments on commit 9e8364a

Please sign in to comment.