diff --git a/ee_plugin/ee_plugin.py b/ee_plugin/ee_plugin.py index e5bd043..5e6ef0d 100644 --- a/ee_plugin/ee_plugin.py +++ b/ee_plugin/ee_plugin.py @@ -89,8 +89,7 @@ def tr(self, message): :returns: Translated version of message. :rtype: QString """ - # noinspection PyTypeChecker,PyArgumentList,PyCallByClass - return QCoreApplication.translate("GoogleEarthEngine", message) + return utils.translate(message) def initGui(self): """Initialize the plugin GUI.""" diff --git a/ee_plugin/ui/forms.py b/ee_plugin/ui/forms.py index 4289046..151a79b 100644 --- a/ee_plugin/ui/forms.py +++ b/ee_plugin/ui/forms.py @@ -10,6 +10,7 @@ ) from .. import Map, utils +from ..utils import translate as _ def DefaultNullQgsDateEdit( @@ -36,53 +37,61 @@ def add_feature_collection_form( ) -> QtWidgets.QDialog: """Add a GEE Feature Collection to the map.""" dialog = build_vbox_dialog( - windowTitle="Add Feature Collection", + windowTitle=_("Add Feature Collection"), widgets=[ build_form_group_box( - title="Source", + title=_("Source"), rows=[ ( QtWidgets.QLabel( + toolTip=_("The Earth Engine Feature Collection ID."), text="
".join( [ - "Add GEE Feature Collection to Map", + _("Feature Collection ID"), "e.g. USGS/WBD/2017/HUC06", ] ), ), QtWidgets.QLineEdit( objectName="feature_collection_id", - whatsThis=( + ), + ), + ( + QtWidgets.QLabel( + _("Retain as a vector layer"), + toolTip=_( + "Store as a vector layer rather than WMS Raster layer." + ), + whatsThis=_( "Attempt to retain the layer as a vector layer, running " "the risk of encountering Earth Engine API limitations if " "the layer is large. Otherwise, the layer will be added as " "a WMS raster layer." ), ), - ), - ( - "Retain as a vector layer", - QtWidgets.QCheckBox(objectName="as_vector"), + QtWidgets.QCheckBox( + objectName="as_vector", + ), ), ], ), build_form_group_box( - title="Filter by Properties", + title=_("Filter by Properties"), collapsable=True, collapsed=True, rows=[ ( - "Name", + _("Name"), QtWidgets.QLineEdit(objectName="filter_name"), ), ( - "Value", + _("Value"), QtWidgets.QLineEdit(objectName="filter_value"), ), ], ), build_form_group_box( - title="Filter by Dates", + title=_("Filter by Dates"), collapsable=True, collapsed=True, rows=[ @@ -98,15 +107,18 @@ def add_feature_collection_form( ), gui.QgsExtentGroupBox( objectName="extent", - title="Filter by Coordinates", + title=_("Filter by Coordinates"), collapsed=True, ), build_form_group_box( - title="Visualization", + title=_("Visualization"), collapsable=True, collapsed=True, rows=[ - ("Color", gui.QgsColorButton(objectName="viz_color_hex")), + ( + _("Color"), + gui.QgsColorButton(objectName="viz_color_hex"), + ), ], ), ], diff --git a/ee_plugin/utils.py b/ee_plugin/utils.py index 1b9650c..ccc02b8 100644 --- a/ee_plugin/utils.py +++ b/ee_plugin/utils.py @@ -10,6 +10,7 @@ import ee import qgis from qgis.core import QgsProject, QgsRasterLayer, QgsVectorLayer, QgsMapLayer +from qgis.PyQt.QtCore import QCoreApplication class VisualizeParams(TypedDict, total=False): @@ -293,3 +294,10 @@ def check_version() -> None: Check if we have the latest plugin version. """ qgis.utils.plugins["ee_plugin"].check_version() + + +def translate(message: str) -> str: + """ + Helper to translate messages. + """ + return QCoreApplication.translate("GoogleEarthEngine", message)