From d5615fc6a6593f247d74a90b7444e711e6dcaa35 Mon Sep 17 00:00:00 2001 From: Roy Date: Wed, 26 Jan 2022 11:43:04 +0100 Subject: [PATCH] Draft: Fix several translation issues --- src/Mod/Draft/DraftGui.py | 6 +-- src/Mod/Draft/draftguitools/gui_beziers.py | 30 ++++++------- src/Mod/Draft/draftguitools/gui_groups.py | 5 +-- src/Mod/Draft/draftguitools/gui_orthoarray.py | 4 +- src/Mod/Draft/draftutils/init_tools.py | 2 +- src/Mod/Draft/draftutils/translate.py | 44 ------------------- src/Mod/Draft/draftviewproviders/view_base.py | 12 ++--- 7 files changed, 29 insertions(+), 74 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index 6662e04ec5..7b4e928f21 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -691,7 +691,7 @@ class DraftToolBar: self.autoGroupButton = self._pushbutton( "autoGroup", self.bottomtray,icon=":/icons/button_invalid.svg", hide=False, width=120) - self.autoGroupButton.setText("None") + self.autoGroupButton.setText(translate("draft", "None")) self.autoGroupButton.setFlat(True) QtCore.QObject.connect(self.wplabel,QtCore.SIGNAL("pressed()"),self.selectplane) @@ -2044,7 +2044,7 @@ class DraftToolBar: def setAutoGroup(self,value=None): if value is None: self.autogroup = None - self.autoGroupButton.setText("None") + self.autoGroupButton.setText(translate("draft", "None")) self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_off', QtGui.QIcon(':/icons/button_invalid.svg'))) self.autoGroupButton.setToolTip(translate("draft", "Autogroup off")) @@ -2059,7 +2059,7 @@ class DraftToolBar: self.autoGroupButton.setDown(False) else: self.autogroup = None - self.autoGroupButton.setText("None") + self.autoGroupButton.setText(translate("draft", "None")) self.autoGroupButton.setIcon(QtGui.QIcon.fromTheme('Draft_AutoGroup_off', QtGui.QIcon(':/icons/button_invalid.svg'))) self.autoGroupButton.setToolTip(translate("draft", "Autogroup off")) diff --git a/src/Mod/Draft/draftguitools/gui_beziers.py b/src/Mod/Draft/draftguitools/gui_beziers.py index b5d3c14bf6..56dc7654fa 100644 --- a/src/Mod/Draft/draftguitools/gui_beziers.py +++ b/src/Mod/Draft/draftguitools/gui_beziers.py @@ -24,7 +24,7 @@ # *************************************************************************** """Provides GUI tools to create BezCurve objects. -In particular, a cubic Bezier curve is defined, as it is one of the most +In particular, a cubic Bézier curve is defined, as it is one of the most useful curves for many applications. See https://en.wikipedia.org/wiki/B%C3%A9zier_curve @@ -50,7 +50,7 @@ from draftutils.translate import translate class BezCurve(gui_lines.Line): - """Gui command for the Bezier Curve tool.""" + """Gui command for the Bézier Curve tool.""" def __init__(self): super(BezCurve, self).__init__(wiremode=True) @@ -60,14 +60,14 @@ class BezCurve(gui_lines.Line): """Set icon, menu and tooltip.""" return {'Pixmap': 'Draft_BezCurve', - 'Accel': "B, Z", - 'MenuText': QT_TRANSLATE_NOOP("Draft_BezCurve", "Bezier curve"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_BezCurve", "Creates an N-degree Bezier curve. The more points you pick, the higher the degree.\nCTRL to snap, SHIFT to constrain.")} + 'Accel': 'B, Z', + 'MenuText': QT_TRANSLATE_NOOP('Draft_BezCurve', 'Bézier curve'), + 'ToolTip': QT_TRANSLATE_NOOP('Draft_BezCurve', 'Creates an N-degree Bézier curve. The more points you pick, the higher the degree.\nCTRL to snap, SHIFT to constrain.')} def Activated(self): """Execute when the command is called. - Activate the specific bezier curve tracker. + Activate the specific Bézier curve tracker. """ super(BezCurve, self).Activated(name="BezCurve", icon="Draft_BezCurve") @@ -129,7 +129,7 @@ class BezCurve(gui_lines.Line): self.undolast() self.finish(True, cont=True) _msg(translate("draft", - "Bezier curve has been closed")) + "Bézier curve has been closed")) def undolast(self): """Undo last line segment.""" @@ -228,7 +228,7 @@ Gui.addCommand('Draft_BezCurve', BezCurve()) class CubicBezCurve(gui_lines.Line): - """Gui command for the 3rd degree Bezier Curve tool.""" + """Gui command for the 3rd degree Bézier Curve tool.""" def __init__(self): super(CubicBezCurve, self).__init__(wiremode=True) @@ -238,9 +238,9 @@ class CubicBezCurve(gui_lines.Line): """Set icon, menu and tooltip.""" return {'Pixmap': 'Draft_CubicBezCurve', - # 'Accel': "B, Z", - 'MenuText': QT_TRANSLATE_NOOP("Draft_CubicBezCurve", "Cubic bezier curve"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_CubicBezCurve", "Creates a Bezier curve made of 2nd degree (quadratic) and 3rd degree (cubic) segments. Click and drag to define each segment.\nAfter the curve is created you can go back to edit each control point and set the properties of each knot.\nCTRL to snap, SHIFT to constrain.")} + # 'Accel': 'B, Z', + 'MenuText': QT_TRANSLATE_NOOP('Draft_CubicBezCurve', 'Cubic Bézier curve'), + 'ToolTip': QT_TRANSLATE_NOOP('Draft_CubicBezCurve', 'Creates a Bézier curve made of 2nd degree (quadratic) and 3rd degree (cubic) segments. Click and drag to define each segment.\nAfter the curve is created you can go back to edit each control point and set the properties of each knot.\nCTRL to snap, SHIFT to constrain.')} def Activated(self): """Execute when the command is called. @@ -329,7 +329,7 @@ class CubicBezCurve(gui_lines.Line): self.node.append(_sym) self.finish(True, cont=True) _msg(translate("draft", - "Bezier curve has been closed")) + "Bézier curve has been closed")) # Release the held button if arg["State"] == "UP" and arg["Button"] == "BUTTON1": @@ -468,12 +468,12 @@ Gui.addCommand('Draft_CubicBezCurve', CubicBezCurve()) class BezierGroup: - """Gui Command group for the Bezier curve tools.""" + """Gui Command group for the Bézier curve tools.""" def GetResources(self): """Set icon, menu and tooltip.""" - return {'MenuText': QT_TRANSLATE_NOOP("Draft_BezierTools", "Bezier tools"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_BezierTools", "Create various types of Bezier curves.")} + return {'MenuText': QT_TRANSLATE_NOOP('Draft_BezierTools', 'Bézier tools'), + 'ToolTip': QT_TRANSLATE_NOOP('Draft_BezierTools', 'Create various types of Bézier curves.')} def GetCommands(self): """Return a tuple of commands in the group.""" diff --git a/src/Mod/Draft/draftguitools/gui_groups.py b/src/Mod/Draft/draftguitools/gui_groups.py index 3a599c9b75..61bcb69929 100644 --- a/src/Mod/Draft/draftguitools/gui_groups.py +++ b/src/Mod/Draft/draftguitools/gui_groups.py @@ -235,7 +235,7 @@ class SetAutoGroup(gui_base.GuiCommandSimplest): # Otherwise it builds a list of layers, with names and icons, # including the options "None" and "Add new layer". - self.groups = ["None"] + self.groups = [translate("draft", "None")] gn = [o.Name for o in self.doc.Objects if utils.get_type(o) == "Layer"] if params.GetBool("AutogroupAddGroups", False): gn.extend(groups.get_group_names()) @@ -389,11 +389,10 @@ class Ui_AddNamedGroup(): def accept(self): - group = App.activeDocument().addObject("App::DocumentObjectGroup",translate("Gui::Dialog::DlgAddProperty","Group")) + group = App.activeDocument().addObject("App::DocumentObjectGroup",translate("draft", "Group")) group.Label=self.name.text() moveToGroup(group) Gui.Control.closeDialog() - ## @} diff --git a/src/Mod/Draft/draftguitools/gui_orthoarray.py b/src/Mod/Draft/draftguitools/gui_orthoarray.py index e9fedc4c2a..fbbb3ef17d 100644 --- a/src/Mod/Draft/draftguitools/gui_orthoarray.py +++ b/src/Mod/Draft/draftguitools/gui_orthoarray.py @@ -62,8 +62,8 @@ class OrthoArray(gui_base.GuiCommandBase): def GetResources(self): """Set icon, menu and tooltip.""" return {'Pixmap': 'Draft_Array', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Array", "Array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Array", "Creates copies of the selected object, and places the copies in an orthogonal pattern,\nmeaning the copies follow the specified direction in the X, Y, Z axes.\n\nThe array can be turned into a polar or a circular array by changing its type.")} + 'MenuText': QT_TRANSLATE_NOOP('Draft_OrthoArray', 'Array'), + 'ToolTip': QT_TRANSLATE_NOOP('Draft_OrthoArray', 'Creates copies of the selected object, and places the copies in an orthogonal pattern,\nmeaning the copies follow the specified direction in the X, Y, Z axes.\n\nThe array can be turned into a polar or a circular array by changing its type.')} def Activated(self): """Execute when the command is called. diff --git a/src/Mod/Draft/draftutils/init_tools.py b/src/Mod/Draft/draftutils/init_tools.py index ceb0f076dd..b468bfb9e1 100644 --- a/src/Mod/Draft/draftutils/init_tools.py +++ b/src/Mod/Draft/draftutils/init_tools.py @@ -55,7 +55,7 @@ def get_draft_drawing_commands(): "Draft_Rectangle", "Draft_Polygon", "Draft_BSpline", - ([QT_TRANSLATE_NOOP("Workbench", "Bezier tools")], + ([QT_TRANSLATE_NOOP("Workbench", "Bézier tools")], list(bez_group.GetCommands(bez_group))), ("Draft_BezierTools", ), "Draft_Point", diff --git a/src/Mod/Draft/draftutils/translate.py b/src/Mod/Draft/draftutils/translate.py index 1e014a8dcf..0b8fe77427 100644 --- a/src/Mod/Draft/draftutils/translate.py +++ b/src/Mod/Draft/draftutils/translate.py @@ -205,48 +205,4 @@ def translate(context, text, utf8_decode=False): QT_TRANSLATE_NOOP = QtCore.QT_TRANSLATE_NOOP -def _tr(text): - """Translate with the context set to Draft. Our own function. - - It uses our own `translate` defined function which internally still - uses `QtCore.QCoreApplication.translate`. - - This is normally used inside a function that prints text. - - >>> print(tr("Some text that will be translated")) - - Parameters - ---------- - text : str - Any text string. - - Returns - ------- - str - Returns the translated string at runtime. - """ - return translate("Draft", text) - - -def _qtr(text): - """Translate with the context set to Draft. QtCore function. - - It uses `QtCore.QT_TRANSLATE_NOOP` function to perform translation. - - This is normally used inside a function that prints text. - - >>> print(qtr("Some text that will be translated")) - - Parameters - ---------- - text : str - Any text string. - - Returns - ------- - str - Returns the translated string at runtime. - """ - return QT_TRANSLATE_NOOP("Draft", text) - ## @} diff --git a/src/Mod/Draft/draftviewproviders/view_base.py b/src/Mod/Draft/draftviewproviders/view_base.py index 5f0e1153ab..d1344ae1b2 100644 --- a/src/Mod/Draft/draftviewproviders/view_base.py +++ b/src/Mod/Draft/draftviewproviders/view_base.py @@ -99,21 +99,21 @@ class ViewProviderDraft(object): def _set_properties(self, vobj): """Set the properties of objects if they don't exist.""" if not hasattr(vobj, "Pattern"): - _tip = "Defines a hatch pattern." vobj.addProperty("App::PropertyEnumeration", "Pattern", "Draft", - QT_TRANSLATE_NOOP("App::Property", _tip)) + QT_TRANSLATE_NOOP("App::Property", + "Defines an SVG pattern.")) patterns = list(utils.svg_patterns().keys()) patterns.sort() vobj.Pattern = ["None"] + patterns if not hasattr(vobj, "PatternSize"): - _tip = "Defines the size of the hatch pattern." vobj.addProperty("App::PropertyFloat", "PatternSize", "Draft", - QT_TRANSLATE_NOOP("App::Property", _tip)) + QT_TRANSLATE_NOOP("App::Property", + "Defines the size of the SVG pattern.")) vobj.PatternSize = utils.get_param("HatchPatternSize", 1) def __getstate__(self): @@ -398,8 +398,8 @@ class ViewProviderDraft(object): Gui.runCommand("Draft_Edit") return True else: - _wrn = "Please load the Draft Workbench to enable editing this object" - App.Console.PrintWarning(QT_TRANSLATE_NOOP("Draft", _wrn)) + App.Console.PrintWarning(QT_TRANSLATE_NOOP("draft", + "Please load the Draft Workbench to enable editing this object")) return False def unsetEdit(self, vobj, mode=0):