Skip to content

Commit

Permalink
BUG: Make more strings translatable
Browse files Browse the repository at this point in the history
Marked strings that were found to be non-translatable in Slicer/SlicerLanguagePacks#41
  • Loading branch information
lassoan committed Sep 26, 2023
1 parent d948581 commit de2011f
Show file tree
Hide file tree
Showing 15 changed files with 373 additions and 339 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import qt

import slicer
from slicer.i18n import tr as _
from slicer.i18n import translate
from slicer.ScriptedLoadableModule import *
from slicer.util import TESTING_DATA_URL

Expand All @@ -19,19 +21,20 @@ class ScriptedLoadableModuleTemplate(ScriptedLoadableModule):

def __init__(self, parent):
ScriptedLoadableModule.__init__(self, parent)
self.parent.title = "ScriptedLoadableModuleTemplate" # TODO make this more human readable by adding spaces
self.parent.categories = ["Examples"]
self.parent.title = _("ScriptedLoadableModuleTemplate") # TODO make this more human readable by adding spaces
self.parent.categories = [translate("qSlicerAbstractCoreModule", "Examples")]
self.parent.dependencies = []
self.parent.contributors = ["John Doe (AnyWare Corp.)"] # replace with "Firstname Lastname (Organization)"
self.parent.helpText = """
# _() function marks text as translatable to other languages
self.parent.helpText = _("""
This is an example of scripted loadable module bundled in an extension.
It performs a simple thresholding on the input volume and optionally captures a screenshot.
"""
""")
self.parent.helpText += self.getDefaultModuleDocumentationLink()
self.parent.acknowledgementText = """
self.parent.acknowledgementText = _("""
This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
and Steve Pieper, Isomics, Inc. and was partially funded by NIH grant 3P41RR013218-12S1.
""" # replace with organization, grant and thanks.
""") # replace with organization, grant and thanks.

#
# ScriptedLoadableModuleTemplateWidget
Expand Down Expand Up @@ -70,8 +73,8 @@ def setup(self):
self.inputSelector.showHidden = False
self.inputSelector.showChildNodeTypes = False
self.inputSelector.setMRMLScene(slicer.mrmlScene)
self.inputSelector.setToolTip("Pick the input to the algorithm.")
parametersFormLayout.addRow("Input Volume: ", self.inputSelector)
self.inputSelector.setToolTip(_("Pick the input to the algorithm."))
parametersFormLayout.addRow(_("Input Volume: "), self.inputSelector)

#
# output volume selector
Expand All @@ -85,8 +88,8 @@ def setup(self):
self.outputSelector.showHidden = False
self.outputSelector.showChildNodeTypes = False
self.outputSelector.setMRMLScene(slicer.mrmlScene)
self.outputSelector.setToolTip("Pick the output to the algorithm.")
parametersFormLayout.addRow("Output Volume: ", self.outputSelector)
self.outputSelector.setToolTip(_("Pick the output to the algorithm."))
parametersFormLayout.addRow(_("Output Volume: "), self.outputSelector)

#
# threshold value
Expand All @@ -96,22 +99,23 @@ def setup(self):
self.imageThresholdSliderWidget.minimum = -100
self.imageThresholdSliderWidget.maximum = 100
self.imageThresholdSliderWidget.value = 0.5
self.imageThresholdSliderWidget.setToolTip("Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero.")
parametersFormLayout.addRow("Image threshold", self.imageThresholdSliderWidget)
self.imageThresholdSliderWidget.setToolTip(
_("Set threshold value for computing the output image. Voxels that have intensities lower than this value will set to zero."))
parametersFormLayout.addRow(_("Image threshold"), self.imageThresholdSliderWidget)

#
# check box to trigger taking screen shots for later use in tutorials
#
self.enableScreenshotsFlagCheckBox = qt.QCheckBox()
self.enableScreenshotsFlagCheckBox.checked = 0
self.enableScreenshotsFlagCheckBox.setToolTip("If checked, take screen shots for tutorials. Use Save Data to write them to disk.")
parametersFormLayout.addRow("Enable Screenshots", self.enableScreenshotsFlagCheckBox)
self.enableScreenshotsFlagCheckBox.setToolTip(_("If checked, take screen shots for tutorials. Use Save Data to write them to disk."))
parametersFormLayout.addRow(_("Enable Screenshots"), self.enableScreenshotsFlagCheckBox)

#
# Apply Button
#
self.applyButton = qt.QPushButton("Apply")
self.applyButton.toolTip = "Run the algorithm."
self.applyButton = qt.QPushButton(_("Apply"))
self.applyButton.toolTip = _("Run the algorithm.")
self.applyButton.enabled = False
parametersFormLayout.addRow(self.applyButton)

Expand Down Expand Up @@ -186,7 +190,7 @@ def run(self, inputVolume, outputVolume, imageThreshold):
"""

if not self.isValidInputOutputData(inputVolume, outputVolume):
slicer.util.errorDisplay('Input volume is the same as output volume. Choose a different output volume.')
slicer.util.errorDisplay(_('Input volume is the same as output volume. Choose a different output volume.'))
return False

logging.info('Processing started')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import vtk

import slicer
from slicer.i18n import tr as _
from slicer.i18n import translate
from slicer.ScriptedLoadableModule import *


Expand All @@ -12,14 +14,14 @@ class SegmentEditorScriptedSegmentEditorEffectModuleTemplate(ScriptedLoadableMod

def __init__(self, parent):
ScriptedLoadableModule.__init__(self, parent)
self.parent.title = "SegmentEditorScriptedSegmentEditorEffectModuleTemplate"
self.parent.categories = ["Segmentation"]
self.parent.title = _("SegmentEditorScriptedSegmentEditorEffectModuleTemplate")
self.parent.categories = [translate("qSlicerAbstractCoreModule", "Segmentation")]
self.parent.dependencies = ["Segmentations"]
self.parent.contributors = ["Andras Lasso (PerkLab)"]
self.parent.hidden = True
self.parent.helpText = "This hidden module registers the segment editor effect"
self.parent.helpText = _("This hidden module registers the segment editor effect")
self.parent.helpText += self.getDefaultModuleDocumentationLink()
self.parent.acknowledgementText = "Supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See https://www.slicer.org for details."
self.parent.acknowledgementText = _("Supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community. See https://www.slicer.org for details.")
slicer.app.connect("startupCompleted()", self.registerEditorEffect)

def registerEditorEffect(self):
Expand Down
4 changes: 2 additions & 2 deletions Modules/Loadable/Models/qSlicerModelsModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ qSlicerModelsModule::~qSlicerModelsModule() = default;
//-----------------------------------------------------------------------------
QString qSlicerModelsModule::helpText()const
{
QString help =
QString help = tr(
"The Models Module loads and adjusts display parameters of models such as Color, Transparency, and Clipping.<br>"
"Save models via the File menu, Save button.<br>"
"The Add 3D model or a model directory button will allow you to load any "
Expand All @@ -86,7 +86,7 @@ QString qSlicerModelsModule::helpText()const
"Clipping is turned on for a model in the Display pane, and the slice "
"planes that will clip the model are selected in the Clipping pane.<br>"
"The Model Hierarchy pane allows you to group models together and set the "
"group's properties.";
"group's properties.");
help += this->defaultDocumentationLink();
return help;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ QString qSlicerVolumeRenderingModule::helpText()const
QString qSlicerVolumeRenderingModule::acknowledgementText()const
{
QString acknowledgement =
tr("<center><table border=\"0\"><tr>"
"<center><table border=\"0\"><tr>"
"<td><img src=\":Logos/NAMIC.png\" alt\"NA-MIC\"></td>"
"<td><img src=\":Logos/NAC.png\" alt\"NAC\"></td>"
"</tr><tr>"
"<td><img src=\":Logos/BIRN-NoText.png\" alt\"BIRN\"></td>"
"<td><img src=\":Logos/NCIGT.png\" alt\"NCIGT\"></td>"
"</tr></table></center>"
"This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community."
"Some of the transfer functions were contributed by Kitware Inc. (VolView)");
+ tr("This work is supported by NA-MIC, NAC, BIRN, NCIGT, and the Slicer Community."
" Some of the transfer functions were contributed by Kitware Inc. (VolView)");
return acknowledgement;
}

Expand Down
32 changes: 17 additions & 15 deletions Modules/Scripted/CropVolumeSequence/CropVolumeSequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import vtk

import slicer
from slicer.i18n import tr as _
from slicer.i18n import translate
from slicer.ScriptedLoadableModule import *


Expand All @@ -20,14 +22,14 @@ class CropVolumeSequence(ScriptedLoadableModule):
def __init__(self, parent):
ScriptedLoadableModule.__init__(self, parent)
self.parent.title = "Crop volume sequence"
self.parent.categories = ["Sequences"]
self.parent.categories = [translate("qSlicerAbstractCoreModule", "Sequences")]
self.parent.dependencies = []
self.parent.contributors = ["Andras Lasso (PerkLab, Queen's University)"]
self.parent.helpText = """This module can crop and resample a volume sequence to reduce its size for faster rendering and processing."""
self.parent.helpText = _("""This module can crop and resample a volume sequence to reduce its size for faster rendering and processing.""")
self.parent.helpText += self.getDefaultModuleDocumentationLink()
self.parent.acknowledgementText = """
self.parent.acknowledgementText = _("""
This file was originally developed by Andras Lasso
"""
""")


#
Expand All @@ -48,7 +50,7 @@ def setup(self):
# Parameters Area
#
parametersCollapsibleButton = ctk.ctkCollapsibleButton()
parametersCollapsibleButton.text = "Parameters"
parametersCollapsibleButton.text = _("Parameters")
self.layout.addWidget(parametersCollapsibleButton)

# Layout within the dummy collapsible button
Expand All @@ -65,8 +67,8 @@ def setup(self):
self.inputSelector.showHidden = False
self.inputSelector.showChildNodeTypes = False
self.inputSelector.setMRMLScene(slicer.mrmlScene)
self.inputSelector.setToolTip("Pick a sequence node of volumes that will be cropped and resampled.")
parametersFormLayout.addRow("Input volume sequence: ", self.inputSelector)
self.inputSelector.setToolTip(_("Pick a sequence node of volumes that will be cropped and resampled."))
parametersFormLayout.addRow(_("Input volume sequence: "), self.inputSelector)

#
# output volume selector
Expand All @@ -77,12 +79,12 @@ def setup(self):
self.outputSelector.addEnabled = True
self.outputSelector.removeEnabled = True
self.outputSelector.noneEnabled = True
self.outputSelector.noneDisplay = "(Overwrite input)"
self.outputSelector.noneDisplay = _("(Overwrite input)")
self.outputSelector.showHidden = False
self.outputSelector.showChildNodeTypes = False
self.outputSelector.setMRMLScene(slicer.mrmlScene)
self.outputSelector.setToolTip("Pick a sequence node where the cropped and resampled volumes will be stored.")
parametersFormLayout.addRow("Output volume sequence: ", self.outputSelector)
self.outputSelector.setToolTip(_("Pick a sequence node where the cropped and resampled volumes will be stored."))
parametersFormLayout.addRow(_("Output volume sequence: "), self.outputSelector)

#
# Crop parameters selector
Expand All @@ -97,23 +99,23 @@ def setup(self):
self.cropParametersSelector.showHidden = True
self.cropParametersSelector.showChildNodeTypes = False
self.cropParametersSelector.setMRMLScene(slicer.mrmlScene)
self.cropParametersSelector.setToolTip("Select a crop volumes parameters.")
self.cropParametersSelector.setToolTip(_("Select a crop volumes parameters."))

self.editCropParametersButton = qt.QPushButton()
self.editCropParametersButton.setIcon(qt.QIcon(':Icons/Go.png'))
# self.editCropParametersButton.setMaximumWidth(60)
self.editCropParametersButton.enabled = True
self.editCropParametersButton.toolTip = "Go to Crop Volume module to edit cropping parameters."
self.editCropParametersButton.toolTip = _("Go to Crop Volume module to edit cropping parameters.")
hbox = qt.QHBoxLayout()
hbox.addWidget(self.cropParametersSelector)
hbox.addWidget(self.editCropParametersButton)
parametersFormLayout.addRow("Crop volume settings: ", hbox)
parametersFormLayout.addRow(_("Crop volume settings: "), hbox)

#
# Apply Button
#
self.applyButton = qt.QPushButton("Apply")
self.applyButton.toolTip = "Run the algorithm."
self.applyButton = qt.QPushButton(_("Apply"))
self.applyButton.toolTip = _("Run the algorithm.")
self.applyButton.enabled = False
parametersFormLayout.addRow(self.applyButton)

Expand Down
18 changes: 10 additions & 8 deletions Modules/Scripted/DMRIInstall/DMRIInstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import qt

import slicer
from slicer.i18n import tr as _
from slicer.i18n import translate
from slicer.ScriptedLoadableModule import *


Expand Down Expand Up @@ -64,18 +66,18 @@ def __init__(self, parent):

ScriptedLoadableModule.__init__(self, parent)

self.parent.categories = ["Diffusion"]
self.parent.title = "Install Slicer Diffusion Tools (SlicerDMRI)"
self.parent.categories = [translate("qSlicerAbstractCoreModule", "Diffusion")]
self.parent.title = _("Install Slicer Diffusion Tools (SlicerDMRI)")
self.parent.dependencies = []
self.parent.contributors = ["Isaiah Norton (BWH), Lauren O'Donnell (BWH)"]
self.parent.helpText = DMRIInstall.helpText
self.parent.helpText += self.getDefaultModuleDocumentationLink()
self.parent.acknowledgementText = textwrap.dedent(
"""
_("""
SlicerDMRI supported by NIH NCI ITCR U01CA199459 (Open Source Diffusion MRI
Technology For Brain Cancer Research), and made possible by NA-MIC, NAC,
BIRN, NCIGT, and the Slicer Community.
""")
"""))


class DMRIInstallWidget(ScriptedLoadableModuleWidget):
Expand All @@ -94,8 +96,8 @@ def setup(self):
#
# Apply Button
#
self.applyButton = qt.QPushButton("Install SlicerDMRI")
self.applyButton.toolTip = 'Installs the "SlicerDMRI" extension from the Diffusion category.'
self.applyButton = qt.QPushButton(_("Install SlicerDMRI"))
self.applyButton.toolTip = _('Installs the "SlicerDMRI" extension from the Diffusion category.')
self.applyButton.icon = qt.QIcon(":/Icons/ExtensionDefaultIcon.png")
self.applyButton.enabled = True
self.applyButton.connect('clicked()', self.onApply)
Expand All @@ -112,7 +114,7 @@ def onApply(self):
emm = slicer.app.extensionsManagerModel()

if emm.isExtensionInstalled("SlicerDMRI"):
self.textBox.setHtml("<h4>SlicerDMRI is already installed.<h4>")
self.textBox.setHtml("<h4>" + _("SlicerDMRI is already installed.") + "<h4>")
self.applyButton.enabled = False
return

Expand All @@ -122,4 +124,4 @@ def onApply(self):
if not emm.downloadAndInstallExtensionByName(extensionName, True, True): # install dependencies, wait for installation to finish
return self.onError()

slicer.app.confirmRestart("Restart to complete SlicerDMRI installation?")
slicer.app.confirmRestart(_("Restart to complete SlicerDMRI installation?"))

0 comments on commit de2011f

Please sign in to comment.