Class: QgsProjectTranslator¶
An interface for objects which can translate project strings.
Added in version 3.4.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: translate()
Class Hierarchy¶
Subclasses¶
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc. |
Abstract Methods
Translates a string using the Qt QTranslator mechanism. |
- class qgis.core.QgsProjectTranslator[source]¶
Bases:
object
- abstract translate(self, context: str | None, sourceText: str | None, disambiguation: str | None = None, n: int = -1) str [source]¶
Translates a string using the Qt QTranslator mechanism.
This function can be called from wherever the
QgsReadWriteContext
is available.- Parameters:
context (Optional[str]) – describes the context of the translation, eg the corresponding map layer
sourceText (Optional[str]) – the identifier of the text to translate (usually the original untranslated string)
disambiguation (Optional[str] = None) – optional string providing additional context for the translation
n (int = -1) – optional “object count”, which can alter the translation to account for plural forms
- Return type:
str
- Returns:
the translated string. In the case that there is no QTranslator available, the
sourceText
will be returned unchanged.
Added in version 3.4.