From abee35f38a5e00f4b8f6ff4ec89824cc75a1b7cc Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 12 Feb 2021 14:44:58 +0100 Subject: [PATCH] Draft: Fixed broken translations everywhere --- src/Mod/Draft/draftfunctions/cut.py | 4 +- src/Mod/Draft/draftfunctions/downgrade.py | 24 ++- src/Mod/Draft/draftfunctions/mirror.py | 8 +- src/Mod/Draft/draftfunctions/upgrade.py | 49 +++---- .../gui_annotationstyleeditor.py | 12 +- src/Mod/Draft/draftguitools/gui_arcs.py | 16 +- .../Draft/draftguitools/gui_array_simple.py | 17 +-- src/Mod/Draft/draftguitools/gui_arrays.py | 5 +- src/Mod/Draft/draftguitools/gui_beziers.py | 28 +--- src/Mod/Draft/draftguitools/gui_circles.py | 4 +- .../Draft/draftguitools/gui_circulararray.py | 16 +- src/Mod/Draft/draftguitools/gui_clone.py | 9 +- .../Draft/draftguitools/gui_dimension_ops.py | 9 +- src/Mod/Draft/draftguitools/gui_dimensions.py | 20 +-- src/Mod/Draft/draftguitools/gui_downgrade.py | 12 +- .../Draft/draftguitools/gui_draft2sketch.py | 15 +- src/Mod/Draft/draftguitools/gui_drawing.py | 15 +- src/Mod/Draft/draftguitools/gui_edit.py | 5 +- src/Mod/Draft/draftguitools/gui_ellipses.py | 3 +- .../Draft/draftguitools/gui_facebinders.py | 7 +- src/Mod/Draft/draftguitools/gui_fillets.py | 15 +- src/Mod/Draft/draftguitools/gui_grid.py | 11 +- src/Mod/Draft/draftguitools/gui_groups.py | 48 ++---- src/Mod/Draft/draftguitools/gui_heal.py | 13 +- src/Mod/Draft/draftguitools/gui_join.py | 12 +- src/Mod/Draft/draftguitools/gui_labels.py | 16 +- src/Mod/Draft/draftguitools/gui_layers.py | 11 +- .../draftguitools/gui_line_add_delete.py | 12 +- src/Mod/Draft/draftguitools/gui_lineops.py | 19 +-- src/Mod/Draft/draftguitools/gui_lines.py | 7 +- src/Mod/Draft/draftguitools/gui_lineslope.py | 17 +-- src/Mod/Draft/draftguitools/gui_mirror.py | 4 +- src/Mod/Draft/draftguitools/gui_move.py | 7 +- src/Mod/Draft/draftguitools/gui_offset.py | 14 +- src/Mod/Draft/draftguitools/gui_orthoarray.py | 17 +-- src/Mod/Draft/draftguitools/gui_patharray.py | 31 ++-- .../draftguitools/gui_pathtwistedarray.py | 33 ++--- src/Mod/Draft/draftguitools/gui_planeproxy.py | 13 +- src/Mod/Draft/draftguitools/gui_pointarray.py | 31 +--- src/Mod/Draft/draftguitools/gui_points.py | 7 +- src/Mod/Draft/draftguitools/gui_polararray.py | 16 +- src/Mod/Draft/draftguitools/gui_polygons.py | 6 +- src/Mod/Draft/draftguitools/gui_rectangles.py | 3 +- src/Mod/Draft/draftguitools/gui_rotate.py | 29 +--- src/Mod/Draft/draftguitools/gui_scale.py | 8 +- .../Draft/draftguitools/gui_selectplane.py | 9 +- .../Draft/draftguitools/gui_shape2dview.py | 19 +-- .../Draft/draftguitools/gui_shapestrings.py | 11 +- src/Mod/Draft/draftguitools/gui_snaps.py | 138 ++++++------------ src/Mod/Draft/draftguitools/gui_splines.py | 4 +- src/Mod/Draft/draftguitools/gui_split.py | 12 +- src/Mod/Draft/draftguitools/gui_stretch.py | 11 +- src/Mod/Draft/draftguitools/gui_styles.py | 12 +- .../Draft/draftguitools/gui_subelements.py | 17 +-- src/Mod/Draft/draftguitools/gui_texts.py | 3 +- .../Draft/draftguitools/gui_togglemodes.py | 47 ++---- src/Mod/Draft/draftguitools/gui_trimex.py | 10 +- src/Mod/Draft/draftguitools/gui_upgrade.py | 14 +- .../Draft/draftguitools/gui_wire2spline.py | 11 +- src/Mod/Draft/draftmake/make_arc_3points.py | 38 +++-- src/Mod/Draft/draftmake/make_array.py | 4 +- src/Mod/Draft/draftmake/make_circulararray.py | 12 +- src/Mod/Draft/draftmake/make_dimension.py | 78 +++++----- src/Mod/Draft/draftmake/make_fillet.py | 16 +- src/Mod/Draft/draftmake/make_label.py | 44 +++--- src/Mod/Draft/draftmake/make_layer.py | 30 ++-- src/Mod/Draft/draftmake/make_orthoarray.py | 35 ++--- src/Mod/Draft/draftmake/make_patharray.py | 30 ++-- src/Mod/Draft/draftmake/make_pointarray.py | 14 +- src/Mod/Draft/draftmake/make_polararray.py | 12 +- src/Mod/Draft/draftmake/make_text.py | 15 +- .../Draft/draftobjects/draft_annotation.py | 23 +-- src/Mod/Draft/draftobjects/patharray.py | 71 +++------ .../Draft/draftobjects/pathtwistedarray.py | 22 +-- src/Mod/Draft/draftobjects/pointarray.py | 32 ++-- .../drafttaskpanels/task_circulararray.py | 47 +++--- .../Draft/drafttaskpanels/task_orthoarray.py | 42 +++--- .../Draft/drafttaskpanels/task_polararray.py | 38 +++-- 78 files changed, 560 insertions(+), 1039 deletions(-) diff --git a/src/Mod/Draft/draftfunctions/cut.py b/src/Mod/Draft/draftfunctions/cut.py index e12d85d551..47c9342ac4 100644 --- a/src/Mod/Draft/draftfunctions/cut.py +++ b/src/Mod/Draft/draftfunctions/cut.py @@ -30,7 +30,7 @@ import FreeCAD as App import draftutils.gui_utils as gui_utils -from draftutils.translate import _tr +from draftutils.translate import translate from draftutils.messages import _err @@ -54,7 +54,7 @@ def cut(object1, object2): If there is a problem and the new object can't be created. """ if not App.activeDocument(): - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return obj = App.activeDocument().addObject("Part::Cut", "Cut") diff --git a/src/Mod/Draft/draftfunctions/downgrade.py b/src/Mod/Draft/draftfunctions/downgrade.py index 75ec6e7750..49cf59b28a 100644 --- a/src/Mod/Draft/draftfunctions/downgrade.py +++ b/src/Mod/Draft/draftfunctions/downgrade.py @@ -36,7 +36,7 @@ import draftutils.gui_utils as gui_utils import draftfunctions.cut as cut from draftutils.messages import _msg -from draftutils.translate import _tr +from draftutils.translate import translate def downgrade(objects, delete=False, force=None): @@ -227,7 +227,7 @@ def downgrade(objects, delete=False, force=None): shapify = utils.shapify result = eval(force)(objects) else: - _msg(_tr("Upgrade: Unknown force method:") + " " + force) + _msg(translate("draft","Upgrade: Unknown force method:") + " " + force) result = None else: # applying transformation automatically @@ -235,7 +235,7 @@ def downgrade(objects, delete=False, force=None): if len(objects) == 1 and utils.get_type(objects[0]) == "Block": result = explode(objects[0]) if result: - _msg(_tr("Found 1 block: exploding it")) + _msg(translate("draft","Found 1 block: exploding it")) # we have one multi-solids compound object: extract its solids elif (len(objects) == 1 and hasattr(objects[0], 'Shape') @@ -243,15 +243,14 @@ def downgrade(objects, delete=False, force=None): result = splitCompounds(objects) # print(result) if result: - _msg(_tr("Found 1 multi-solids compound: exploding it")) + _msg(translate("draft","Found 1 multi-solids compound: exploding it")) # special case, we have one parametric object: we "de-parametrize" it elif (len(objects) == 1 and hasattr(objects[0], 'Shape') and hasattr(objects[0], 'Base')): result = utils.shapify(objects[0]) if result: - _msg(_tr("Found 1 parametric object: " - "breaking its dependencies")) + _msg(translate("draft","Found 1 parametric object: breaking its dependencies")) add_list.append(result) # delete_list.append(objects[0]) @@ -259,35 +258,34 @@ def downgrade(objects, delete=False, force=None): elif len(objects) == 2: result = cut2(objects) if result: - _msg(_tr("Found 2 objects: subtracting them")) + _msg(translate("draft","Found 2 objects: subtracting them")) elif len(faces) > 1: # one object with several faces: split it if len(objects) == 1: result = splitFaces(objects) if result: - _msg(_tr("Found several faces: splitting them")) + _msg(translate("draft","Found several faces: splitting them")) # several objects: remove all the faces from the first one else: result = subtr(objects) if result: - _msg(_tr("Found several objects: " - "subtracting them from the first one")) + _msg(translate("draft","Found several objects: subtracting them from the first one")) # only one face: we extract its wires elif len(faces) > 0: result = getWire(objects[0]) if result: - _msg(_tr("Found 1 face: extracting its wires")) + _msg(translate("draft","Found 1 face: extracting its wires")) # no faces: split wire into single edges elif not onlyedges: result = splitWires(objects) if result: - _msg(_tr("Found only wires: extracting their edges")) + _msg(translate("draft","Found only wires: extracting their edges")) # no result has been obtained if not result: - _msg(_tr("No more downgrade possible")) + _msg(translate("draft","No more downgrade possible")) if delete: names = [] diff --git a/src/Mod/Draft/draftfunctions/mirror.py b/src/Mod/Draft/draftfunctions/mirror.py index a58422cd7b..189e424424 100644 --- a/src/Mod/Draft/draftfunctions/mirror.py +++ b/src/Mod/Draft/draftfunctions/mirror.py @@ -37,7 +37,7 @@ import draftutils.utils as utils import draftutils.gui_utils as gui_utils from draftutils.messages import _err -from draftutils.translate import _tr +from draftutils.translate import translate if App.GuiUp: import FreeCADGui as Gui @@ -87,11 +87,11 @@ def mirror(objlist, p1, p2): utils.print_header('mirror', "Create mirror") if not objlist: - _err(_tr("No object given")) + _err(translate("draft","No object given")) return if p1 == p2: - _err(_tr("The two points are coincident")) + _err(translate("draft","The two points are coincident")) return if not isinstance(objlist, list): @@ -110,7 +110,7 @@ def mirror(objlist, p1, p2): for obj in objlist: mir = App.ActiveDocument.addObject("Part::Mirroring", "mirror") - mir.Label = obj.Label + _tr(" (mirrored)") + mir.Label = obj.Label + " (" + translate("draft","mirrored" + ")") mir.Source = obj mir.Base = p1 mir.Normal = pnorm diff --git a/src/Mod/Draft/draftfunctions/upgrade.py b/src/Mod/Draft/draftfunctions/upgrade.py index e328fe7511..d42b979026 100644 --- a/src/Mod/Draft/draftfunctions/upgrade.py +++ b/src/Mod/Draft/draftfunctions/upgrade.py @@ -41,7 +41,7 @@ import draftmake.make_wire as make_wire import draftmake.make_block as make_block from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate from draftgeoutils.geometry import is_straight_line # Delay import of module until first use because it is heavy @@ -148,9 +148,9 @@ def upgrade(objects, delete=False, force=None): delete_list.append(obj) return newobj else: - _err(_tr("Object must be a closed shape")) + _err(translate("draft","Object must be a closed shape")) else: - _err(_tr("No solid object created")) + _err(translate("draft","No solid object created")) return None def closeWire(obj): @@ -273,7 +273,7 @@ def upgrade(objects, delete=False, force=None): if not checked: coplanarity = DraftGeomUtils.is_coplanar(faces, 1e-3) if not coplanarity: - _err(_tr("Faces must be coplanar to be refined")) + _err(translate("draft","Faces must be coplanar to be refined")) return None # fuse faces @@ -429,7 +429,7 @@ def upgrade(objects, delete=False, force=None): if force in all_func: result = all_func[force](objects) else: - _msg(_tr("Upgrade: Unknown force method:") + " " + force) + _msg(translate("draft","Upgrade: Unknown force method:") + " " + force) result = None else: @@ -447,13 +447,13 @@ def upgrade(objects, delete=False, force=None): if groups: result = closeGroupWires(groups) if result: - _msg(_tr("Found groups: closing each open object inside")) + _msg(translate("draft","Found groups: closing each open object inside")) # if we have meshes, we try to turn them into shapes elif meshes: result = turnToParts(meshes) if result: - _msg(_tr("Found meshes: turning into Part shapes")) + _msg(translate("draft","Found meshes: turning into Part shapes")) # we have only faces here, no lone edges elif faces and (len(wires) + len(openwires) == len(facewires)): @@ -461,31 +461,29 @@ def upgrade(objects, delete=False, force=None): if len(objects) == 1 and len(faces) > 3 and not faces_coplanarity: result = makeSolid(objects[0]) if result: - _msg(_tr("Found 1 solidifiable object: solidifying it")) + _msg(translate("draft","Found 1 solidifiable object: solidifying it")) # we have exactly 2 objects: we fuse them elif len(objects) == 2 and not curves and not faces_coplanarity: result = makeFusion(objects[0], objects[1]) if result: - _msg(_tr("Found 2 objects: fusing them")) + _msg(translate("draft","Found 2 objects: fusing them")) # we have many separate faces: we try to make a shell or compound elif len(objects) >= 2 and len(faces) > 1 and not loneedges: result = makeShell(objects) if result: - _msg(_tr("Found several objects: creating a " + _msg(translate("draft","Found several objects: creating a " + str(result.Shape.ShapeType))) # we have faces: we try to join them if they are coplanar elif len(objects) == 1 and len(faces) > 1: result = joinFaces(objects, faces_coplanarity, True) if result: - _msg(_tr("Found object with several coplanar faces: " - "refine them")) + _msg(translate("draft","Found object with several coplanar faces: refine them")) # only one object: if not parametric, we "draftify" it elif (len(objects) == 1 and not objects[0].isDerivedFrom("Part::Part2DObjectPython")): result = ext_draftify.draftify(objects[0]) if result: - _msg(_tr("Found 1 non-parametric objects: " - "draftifying it")) + _msg(translate("draft","Found 1 non-parametric objects: draftifying it")) # in the following cases there are no faces elif not faces: @@ -496,25 +494,24 @@ def upgrade(objects, delete=False, force=None): and objects[0].isDerivedFrom("Sketcher::SketchObject")): result = makeSketchFace(objects[0]) if result: - _msg(_tr("Found 1 closed sketch object: " - "creating a face from it")) + _msg(translate("draft","Found 1 closed sketch object: creating a face from it")) # only closed wires else: result = makeFaces(objects) if result: - _msg(_tr("Found closed wires: creating faces")) + _msg(translate("draft","Found closed wires: creating faces")) # wires or edges: we try to join them elif len(objects) > 1 and len(edges) > 1: result = makeWires(objects) if result: - _msg(_tr("Found several wires or edges: wiring them")) + _msg(translate("draft","Found several wires or edges: wiring them")) # special case, we have only one open wire. We close it, # unless it has only 1 edge! elif len(objects) == 1 and len(openwires) == 1: result = closeWire(objects[0]) - _msg(_tr("trying: closing it")) + _msg(translate("draft","trying: closing it")) if result: - _msg(_tr("Found 1 open wire: closing it")) + _msg(translate("draft","Found 1 open wire: closing it")) # we have only one object that contains one edge # TODO: improve draftify function # only one object: if not parametric, we "draftify" it @@ -522,8 +519,7 @@ def upgrade(objects, delete=False, force=None): # and not objects[0].isDerivedFrom("Part::Part2DObjectPython")): # result = ext_draftify.draftify(objects[0]) # if result: - # _msg(_tr("Found 1 non-parametric objects: " - # "draftifying it")) + # _msg(translate("draft","Found 1 non-parametric objects: draftifying it")) elif (len(objects) == 1 and len(edges) == 1 and not objects[0].isDerivedFrom("Part::Part2DObjectPython")): e = objects[0].Shape.Edges[0] @@ -532,21 +528,20 @@ def upgrade(objects, delete=False, force=None): if edge_type in ("Line", "Circle"): result = ext_draftify.draftify(objects[0]) if result: - _msg(_tr("Found 1 object: draftifying it")) + _msg(translate("draft","Found 1 object: draftifying it")) # only points, no edges elif not edges and len(objects) > 1: result = makeCompound(objects) if result: - _msg(_tr("Found points: creating compound")) + _msg(translate("draft","Found points: creating compound")) # all other cases, if more than 1 object, make a compound elif len(objects) > 1: result = makeCompound(objects) if result: - _msg(_tr("Found several non-treatable objects: " - "creating compound")) + _msg(translate("draft","Found several non-treatable objects: creating compound")) # no result has been obtained if not result: - _msg(_tr("Unable to upgrade these objects.")) + _msg(translate("draft","Unable to upgrade these objects.")) if delete: names = [] diff --git a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py index f7fa02ef8d..cc77853656 100644 --- a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py +++ b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py @@ -35,7 +35,7 @@ import FreeCADGui as Gui import draftguitools.gui_base as gui_base from FreeCAD import Units as U -from draftutils.translate import _tr +from draftutils.translate import translate from draftutils.utils import ANNOTATION_STYLE as DEFAULT param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") @@ -65,7 +65,7 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest): """ def __init__(self): - super(AnnotationStyleEditor, self).__init__(name=_tr("Annotation style editor")) + super(AnnotationStyleEditor, self).__init__(name=translate("draft","Annotation style editor")) self.doc = None self.styles = {} self.renamed = {} @@ -289,9 +289,9 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest): """imports styles from a json file""" filename = QtGui.QFileDialog.getOpenFileName( QtGui.QApplication.activeWindow(), - _tr("Open styles file"), + translate("draft","Open styles file"), None, - _tr("JSON file (*.json)")) + translate("draft","JSON file (*.json)")) if filename and filename[0]: with open(filename[0]) as f: nstyles = json.load(f) @@ -311,9 +311,9 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest): """exports styles to a json file""" filename = QtGui.QFileDialog.getSaveFileName( QtGui.QApplication.activeWindow(), - _tr("Save styles file"), + translate("draft","Save styles file"), None, - _tr("JSON file (*.json)")) + translate("draft","JSON file (*.json)")) if filename and filename[0]: with open(filename[0],"w") as f: json.dump(self.styles,f,indent=4) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index 9352adb188..bb202aa1ea 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -45,7 +45,7 @@ import draftutils.utils as utils from FreeCAD import Units as U from draftutils.messages import _msg, _err -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -60,17 +60,15 @@ class Arc(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a circular arc by a center point and a radius.\n" - "CTRL to snap, SHIFT to constrain.") return {'Pixmap': 'Draft_Arc', 'Accel': "A, R", 'MenuText': QT_TRANSLATE_NOOP("Draft_Arc", "Arc"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Arc", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Arc", "Creates a circular arc by a center point and a radius.\nCTRL to snap, SHIFT to constrain.")} def Activated(self): """Execute when the command is called.""" - super(Arc, self).Activated(name=_tr(self.featureName)) + super(Arc, self).Activated(name=translate("draft","Arc") if self.ui: self.step = 0 self.center = None @@ -480,7 +478,7 @@ class Arc_3Points(gui_base.GuiCommandSimplest): """GuiCommand for the Draft_Arc_3Points tool.""" def __init__(self): - super(Arc_3Points, self).__init__(name=_tr("Arc by 3 points")) + super(Arc_3Points, self).__init__(name=translate("draft","Arc by 3 points")) def GetResources(self): """Set icon, menu and tooltip.""" @@ -596,11 +594,9 @@ class ArcGroup: def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Arc tools" - _tip = ("Create various types of circular arcs.") - return {'MenuText': QT_TRANSLATE_NOOP("Draft_ArcTools", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ArcTools", _tip)} + return {'MenuText': QT_TRANSLATE_NOOP("Draft_ArcTools", "Arc tools"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ArcTools", "Create various types of circular arcs.")} def GetCommands(self): """Return a tuple of commands in the group.""" diff --git a/src/Mod/Draft/draftguitools/gui_array_simple.py b/src/Mod/Draft/draftguitools/gui_array_simple.py index 3d2ddd26b2..248d287bff 100644 --- a/src/Mod/Draft/draftguitools/gui_array_simple.py +++ b/src/Mod/Draft/draftguitools/gui_array_simple.py @@ -41,7 +41,7 @@ import Draft_rc import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -63,16 +63,12 @@ class Array(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates an array from a selected object. " - "By default, it is a 2x2 orthogonal array.\n" - "Once the array is created its type can be changed " - "to polar or circular, and its properties can be modified.") return {'Pixmap': 'Draft_Array', 'MenuText': QT_TRANSLATE_NOOP("Draft_Array", "Array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Array", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Array", "Creates an array from a selected object.\nBy default, it is a 2x2 orthogonal array.\nOnce the array is created its type can be changed\nto polar or circular, and its properties can be modified.")} - def Activated(self, name=_tr("Array")): + def Activated(self, name=translate("draft","Array")): """Execute when the command is called.""" super(Array, self).Activated(name=name) if not Gui.Selection.getSelection(): @@ -118,17 +114,14 @@ class LinkArray(Array): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Like the Array tool, but creates a 'Link array' instead.\n" - "A 'Link array' is more efficient when handling many copies " - "but the 'Fuse' option cannot be used.") return {'Pixmap': 'Draft_LinkArray', 'MenuText': QT_TRANSLATE_NOOP("Draft_LinkArray", "LinkArray"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_LinkArray", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_LinkArray", "Like the Array tool, but creates a 'Link array' instead.\nA 'Link array' is more efficient when handling many copies but the 'Fuse' option cannot be used.")} def Activated(self): """Execute when the command is called.""" - super(LinkArray, self).Activated(name=_tr("Link array")) + super(LinkArray, self).Activated(name=translate("draft","Link array")) Gui.addCommand('Draft_LinkArray', LinkArray()) diff --git a/src/Mod/Draft/draftguitools/gui_arrays.py b/src/Mod/Draft/draftguitools/gui_arrays.py index fad669c793..bda4dc9a8f 100644 --- a/src/Mod/Draft/draftguitools/gui_arrays.py +++ b/src/Mod/Draft/draftguitools/gui_arrays.py @@ -60,13 +60,10 @@ class ArrayGroup: def GetResources(self): """Set icon, menu and tooltip.""" - _tooltip = ("Create various types of arrays, " - "including rectangular, polar, circular, " - "path, and point") return {'Pixmap': 'Draft_Array', 'MenuText': QT_TRANSLATE_NOOP("Draft", "Array tools"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", _tooltip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Create various types of arrays, including rectangular, polar, circular, path, and point")} def IsActive(self): """Return True when this command should be available.""" diff --git a/src/Mod/Draft/draftguitools/gui_beziers.py b/src/Mod/Draft/draftguitools/gui_beziers.py index d93a0f3c6a..044bb03615 100644 --- a/src/Mod/Draft/draftguitools/gui_beziers.py +++ b/src/Mod/Draft/draftguitools/gui_beziers.py @@ -58,15 +58,11 @@ class BezCurve(gui_lines.Line): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Bezier curve" - _tip = ("Creates an N-degree Bezier curve. " - "The more points you pick, the higher the degree.\n" - "CTRL to snap, SHIFT to constrain.") return {'Pixmap': 'Draft_BezCurve', 'Accel': "B, Z", - 'MenuText': QT_TRANSLATE_NOOP("Draft_BezCurve", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_BezCurve", _tip)} + '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.")} def Activated(self): """Execute when the command is called. @@ -239,18 +235,13 @@ class CubicBezCurve(gui_lines.Line): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Cubic bezier curve" - _tip = ("Creates a Bezier curve made of 2nd degree (quadratic) " - "and 3rd degree (cubic) segments. " - "Click and drag to define each segment.\n" - "After the curve is created you can go back to edit " - "each control point and set the properties of each knot.\n" - "CTRL to snap, SHIFT to constrain.") + _menu = + _tip = () return {'Pixmap': 'Draft_CubicBezCurve', # 'Accel': "B, Z", - 'MenuText': QT_TRANSLATE_NOOP("Draft_CubicBezCurve", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_CubicBezCurve", _tip)} + '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.")} def Activated(self): """Execute when the command is called. @@ -481,11 +472,8 @@ class BezierGroup: def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Bezier tools" - _tip = ("Create various types of Bezier curves.") - - return {'MenuText': QT_TRANSLATE_NOOP("Draft_BezierTools", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_BezierTools", _tip)} + return {'MenuText': QT_TRANSLATE_NOOP("Draft_BezierTools", "Bezier tools"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_BezierTools", "Create various types of Bezier curves.")} def GetCommands(self): """Return a tuple of commands in the group.""" diff --git a/src/Mod/Draft/draftguitools/gui_circles.py b/src/Mod/Draft/draftguitools/gui_circles.py index 23378b2985..08b3cf507f 100644 --- a/src/Mod/Draft/draftguitools/gui_circles.py +++ b/src/Mod/Draft/draftguitools/gui_circles.py @@ -73,13 +73,11 @@ class Circle(gui_arcs.Arc): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a circle (full circular arc).\n" - "CTRL to snap, ALT to select tangent objects.") return {'Pixmap': 'Draft_Circle', 'Accel': "C, I", 'MenuText': QT_TRANSLATE_NOOP("Draft_Circle", "Circle"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Circle", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Circle", "Creates a circle (full circular arc).\nCTRL to snap, ALT to select tangent objects.")} Gui.addCommand('Draft_Circle', Circle()) diff --git a/src/Mod/Draft/draftguitools/gui_circulararray.py b/src/Mod/Draft/draftguitools/gui_circulararray.py index e98a8d0d31..cabd1c0ca8 100644 --- a/src/Mod/Draft/draftguitools/gui_circulararray.py +++ b/src/Mod/Draft/draftguitools/gui_circulararray.py @@ -37,7 +37,7 @@ import Draft_rc # include resources, icons, ui files import draftutils.todo as todo from draftutils.messages import _msg, _log -from draftutils.translate import _tr +from draftutils.translate import translate from draftguitools import gui_base from drafttaskpanels import task_circulararray @@ -61,16 +61,10 @@ class CircularArray(gui_base.GuiCommandBase): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates copies of the selected object, " - "and places the copies in a radial pattern\n" - "creating various circular layers.\n" - "\n" - "The array can be turned into an orthogonal " - "or a polar array by changing its type.") d = {'Pixmap': 'Draft_CircularArray', 'MenuText': QT_TRANSLATE_NOOP("Draft", "Circular array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates copies of the selected object, and places the copies in a radial pattern\ncreating various circular layers.\n\nThe array can be turned into an orthogonal or a polar array by changing its type.")} return d def Activated(self): @@ -79,9 +73,9 @@ class CircularArray(gui_base.GuiCommandBase): We add callbacks that connect the 3D view with the widgets of the task panel. """ - _log("GuiCommand: {}".format(_tr(self.command_name))) - _msg("{}".format(16*"-")) - _msg("GuiCommand: {}".format(_tr(self.command_name))) + _log("GuiCommand: {}".format(self.command_name)) + #_msg("{}".format(16*"-")) + #_msg("GuiCommand: {}".format(self.command_name)) self.location = coin.SoLocation2Event.getClassTypeId() self.mouse_event = coin.SoMouseButtonEvent.getClassTypeId() diff --git a/src/Mod/Draft/draftguitools/gui_clone.py b/src/Mod/Draft/draftguitools/gui_clone.py index 1901c5c4e5..26797cefd3 100644 --- a/src/Mod/Draft/draftguitools/gui_clone.py +++ b/src/Mod/Draft/draftguitools/gui_clone.py @@ -49,7 +49,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils import draftutils.todo as todo from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -64,18 +64,15 @@ class Clone(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a clone of the selected objects.\n" - "The resulting clone can be scaled in each " - "of its three directions.") return {'Pixmap': 'Draft_Clone', 'Accel': "C,L", 'MenuText': QT_TRANSLATE_NOOP("Draft_Clone", "Clone"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Clone", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Clone", "Creates a clone of the selected objects.\nThe resulting clone can be scaled in each of its three directions.")} def Activated(self): """Execute when the command is called.""" - super(Clone, self).Activated(name=_tr("Clone")) + super(Clone, self).Activated(name=translate("draft","Clone")) if not Gui.Selection.getSelection(): if self.ui: self.ui.selectUi() diff --git a/src/Mod/Draft/draftguitools/gui_dimension_ops.py b/src/Mod/Draft/draftguitools/gui_dimension_ops.py index c19c75f5f3..6d6a7f96a5 100644 --- a/src/Mod/Draft/draftguitools/gui_dimension_ops.py +++ b/src/Mod/Draft/draftguitools/gui_dimension_ops.py @@ -39,7 +39,7 @@ import FreeCADGui as Gui import draftutils.utils as utils import draftguitools.gui_base as gui_base -from draftutils.translate import _tr +from draftutils.translate import translate class FlipDimension(gui_base.GuiCommandNeedsSelection): @@ -52,19 +52,16 @@ class FlipDimension(gui_base.GuiCommandNeedsSelection): """ def __init__(self): - super(Draft_FlipDimension, self).__init__(name=_tr("Flip dimension")) + super(Draft_FlipDimension, self).__init__(name=translate("draft","Flip dimension")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Flip the normal direction of the selected dimensions " - "(linear, radial, angular).\n" - "If other objects are selected they are ignored.") return {'Pixmap': 'Draft_FlipDimension', 'MenuText': QT_TRANSLATE_NOOP("Draft_FlipDimension", "Flip dimension"), 'ToolTip': QT_TRANSLATE_NOOP("Draft_FlipDimension", - _tip)} + "Flip the normal direction of the selected dimensions (linear, radial, angular).\nIf other objects are selected they are ignored.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_dimensions.py b/src/Mod/Draft/draftguitools/gui_dimensions.py index fcd4b61f2b..a4941e3915 100644 --- a/src/Mod/Draft/draftguitools/gui_dimensions.py +++ b/src/Mod/Draft/draftguitools/gui_dimensions.py @@ -77,29 +77,11 @@ class Dimension(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a dimension.\n" - "\n" - "- Pick three points to create a simple linear dimension.\n" - "- Select a straight line to create a linear dimension " - "linked to that line.\n" - "- Select an arc or circle to create a radius or diameter " - "dimension linked to that arc.\n" - "- Select two straight lines to create an angular dimension " - "between them.\n" - "CTRL to snap, SHIFT to constrain, " - "ALT to select an edge or arc.\n" - "\n" - "You may select a single line or single circular arc " - "before launching this command\n" - "to create the corresponding linked dimension.\n" - "You may also select an 'App::MeasureDistance' object " - "before launching this command\n" - "to turn it into a 'Draft Dimension' object.") return {'Pixmap': 'Draft_Dimension', 'Accel': "D, I", 'MenuText': QT_TRANSLATE_NOOP("Draft_Dimension", "Dimension"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Dimension", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Dimension", "Creates a dimension.\n\n- Pick three points to create a simple linear dimension.\n- Select a straight line to create a linear dimension linked to that line.\n- Select an arc or circle to create a radius or diameter dimension linked to that arc.\n- Select two straight lines to create an angular dimension between them.\nCTRL to snap, SHIFT to constrain, ALT to select an edge or arc.\n\nYou may select a single line or single circular arc before launching this command\nto create the corresponding linked dimension.\nYou may also select an 'App::MeasureDistance' object before launching this command\nto turn it into a 'Draft Dimension' object.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_downgrade.py b/src/Mod/Draft/draftguitools/gui_downgrade.py index dbc056165f..015717681d 100644 --- a/src/Mod/Draft/draftguitools/gui_downgrade.py +++ b/src/Mod/Draft/draftguitools/gui_downgrade.py @@ -41,7 +41,7 @@ import Draft_rc import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -52,21 +52,15 @@ class Downgrade(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Downgrades the selected objects into simpler shapes.\n" - "The result of the operation depends on the types of objects, " - "which may be able to be downgraded several times in a row.\n" - "For example, it explodes the selected polylines " - "into simpler faces, wires, and then edges. " - "It can also subtract faces.") return {'Pixmap': 'Draft_Downgrade', 'Accel': "D, N", 'MenuText': QT_TRANSLATE_NOOP("Draft_Downgrade", "Downgrade"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Downgrade", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Downgrade", "Downgrades the selected objects into simpler shapes.\nThe result of the operation depends on the types of objects, which may be able to be downgraded several times in a row.\nFor example, it explodes the selected polylines into simpler faces, wires, and then edges. It can also subtract faces.")} def Activated(self): """Execute when the command is called.""" - super(Downgrade, self).Activated(name=_tr("Downgrade")) + super(Downgrade, self).Activated(name=translate("draft","Downgrade")) if self.ui: if not Gui.Selection.getSelection(): self.ui.selectUi() diff --git a/src/Mod/Draft/draftguitools/gui_draft2sketch.py b/src/Mod/Draft/draftguitools/gui_draft2sketch.py index d5311d7dbb..2759e6e0ff 100644 --- a/src/Mod/Draft/draftguitools/gui_draft2sketch.py +++ b/src/Mod/Draft/draftguitools/gui_draft2sketch.py @@ -41,7 +41,7 @@ import Draft_rc import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -52,21 +52,14 @@ class Draft2Sketch(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Draft to Sketch" - _tip = ("Convert bidirectionally between Draft objects " - "and Sketches.\n" - "Many Draft objects will be converted into a single " - "non-constrained Sketch.\n" - "However, a single sketch with disconnected traces " - "will be converted into several individual Draft objects.") return {'Pixmap': 'Draft_Draft2Sketch', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Draft2Sketch", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Draft2Sketch", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Draft2Sketch", "Draft to Sketch"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Draft2Sketch", "Convert bidirectionally between Draft objects and Sketches.\nMany Draft objects will be converted into a single non-constrained Sketch.\nHowever, a single sketch with disconnected traces will be converted into several individual Draft objects.")} def Activated(self): """Execute when the command is called.""" - super(Draft2Sketch, self).Activated(name=_tr("Convert Draft/Sketch")) + super(Draft2Sketch, self).Activated(name=translate("draft","Convert Draft/Sketch")) if not Gui.Selection.getSelection(): if self.ui: self.ui.selectUi() diff --git a/src/Mod/Draft/draftguitools/gui_drawing.py b/src/Mod/Draft/draftguitools/gui_drawing.py index 2b4800636c..d34e3ee4e2 100644 --- a/src/Mod/Draft/draftguitools/gui_drawing.py +++ b/src/Mod/Draft/draftguitools/gui_drawing.py @@ -50,7 +50,7 @@ import draftutils.utils as utils import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg, _wrn -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -65,23 +65,16 @@ class Drawing(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a 2D projection on a Drawing Workbench page " - "from the selected objects.\n" - "This command is OBSOLETE since the Drawing Workbench " - "became obsolete in 0.17.\n" - "Use TechDraw Workbench instead for generating " - "technical drawings.") return {'Pixmap': 'Draft_Drawing', # 'Accel': "D, D", 'MenuText': QT_TRANSLATE_NOOP("Draft_Drawing", "Drawing"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Drawing", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Drawing", "Creates a 2D projection on a Drawing Workbench page from the selected objects.\nThis command is OBSOLETE since the Drawing Workbench became obsolete in 0.17.\nUse TechDraw Workbench instead for generating technical drawings.")} def Activated(self): """Execute when the command is called.""" - super(Drawing, self).Activated(name=_tr("Drawing")) - _wrn(_tr("The Drawing Workbench is obsolete since 0.17, " - "consider using the TechDraw Workbench instead.")) + super(Drawing, self).Activated(name=translate("draft","Drawing")) + _wrn(translate("draft","The Drawing Workbench is obsolete since 0.17, consider using the TechDraw Workbench instead.")) if not Gui.Selection.getSelection(): self.ghost = None self.ui.selectUi() diff --git a/src/Mod/Draft/draftguitools/gui_edit.py b/src/Mod/Draft/draftguitools/gui_edit.py index 5533e0da9a..8e7648b14a 100644 --- a/src/Mod/Draft/draftguitools/gui_edit.py +++ b/src/Mod/Draft/draftguitools/gui_edit.py @@ -270,13 +270,10 @@ class Edit(gui_base_original.Modifier): def GetResources(self): - tooltip = ("Edits the active object.\n" - "Press E or ALT+LeftClick to display context menu\n" - "on supported nodes and on supported objects.") return {'Pixmap': 'Draft_Edit', 'Accel': "D, E", 'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_Edit", "Edit"), - 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_Edit", tooltip) + 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_Edit", "Edits the active object.\nPress E or ALT+LeftClick to display context menu\non supported nodes and on supported objects.") } diff --git a/src/Mod/Draft/draftguitools/gui_ellipses.py b/src/Mod/Draft/draftguitools/gui_ellipses.py index 82014b69c1..569d66141c 100644 --- a/src/Mod/Draft/draftguitools/gui_ellipses.py +++ b/src/Mod/Draft/draftguitools/gui_ellipses.py @@ -53,12 +53,11 @@ class Ellipse(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Creates an ellipse. CTRL to snap." return {'Pixmap': 'Draft_Ellipse', 'Accel': "E, L", 'MenuText': QT_TRANSLATE_NOOP("Draft_Ellipse", "Ellipse"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Ellipse", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Ellipse", "Creates an ellipse. CTRL to snap.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_facebinders.py b/src/Mod/Draft/draftguitools/gui_facebinders.py index 7f1879c61b..7a8bf83f0c 100644 --- a/src/Mod/Draft/draftguitools/gui_facebinders.py +++ b/src/Mod/Draft/draftguitools/gui_facebinders.py @@ -43,7 +43,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -54,17 +54,16 @@ class Facebinder(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Creates a facebinder object from selected faces." d = {'Pixmap': 'Draft_Facebinder', 'Accel': "F,F", 'MenuText': QT_TRANSLATE_NOOP("Draft_Facebinder", "Facebinder"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Facebinder", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Facebinder", "Creates a facebinder object from selected faces.")} return d def Activated(self): """Execute when the command is called.""" - super(Facebinder, self).Activated(name=_tr("Facebinder")) + super(Facebinder, self).Activated(name=translate("draft","Facebinder")) if not Gui.Selection.getSelection(): if self.ui: diff --git a/src/Mod/Draft/draftguitools/gui_fillets.py b/src/Mod/Draft/draftguitools/gui_fillets.py index 9da0afe9f4..c4a13b0f81 100644 --- a/src/Mod/Draft/draftguitools/gui_fillets.py +++ b/src/Mod/Draft/draftguitools/gui_fillets.py @@ -44,7 +44,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg, _err -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -58,12 +58,11 @@ class Fillet(gui_base_original.Creator): self.featureName = "Fillet" def GetResources(self): - """Set icon, menu and tooltip.""" - _tip = "Creates a fillet between two selected wires or edges." + """Set icon, menu and tooltip.""" return {'Pixmap': 'Draft_Fillet', 'MenuText': QT_TRANSLATE_NOOP("Draft", "Fillet"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates a fillet between two selected wires or edges.")} def Activated(self, name=translate("Draft", "Fillet")): """Execute when the command is called.""" @@ -110,7 +109,7 @@ class Fillet(gui_base_original.Creator): # self.linetrack = trackers.lineTracker(dotted=True) # self.arctrack = trackers.arcTracker() # self.call = self.view.addEventCallback("SoEvent", self.action) - _msg(_tr("Enter radius.")) + _msg(translate("draft","Enter radius.")) def action(self, arg): """Scene event handler. CURRENTLY NOT USED. @@ -129,12 +128,12 @@ class Fillet(gui_base_original.Creator): def set_delete(self): """Execute as a callback when the delete checkbox changes.""" self.delete = self.ui.check_delete.isChecked() - _msg(_tr("Delete original objects: ") + str(self.delete)) + _msg(translate("draft","Delete original objects:") + " " + str(self.delete)) def set_chamfer(self): """Execute as a callback when the chamfer checkbox changes.""" self.chamfer = self.ui.check_chamfer.isChecked() - _msg(_tr("Chamfer mode: ") + str(self.chamfer)) + _msg(translate("draft","Chamfer mode:") + " " + str(self.chamfer)) def numericRadius(self, rad): """Validate the entry radius in the user interface. @@ -151,7 +150,7 @@ class Fillet(gui_base_original.Creator): wires = Gui.Selection.getSelection() if not wires or len(wires) != 2: - _err(_tr("Two elements needed.")) + _err(translate("draft","Two elements needed.")) return for o in wires: diff --git a/src/Mod/Draft/draftguitools/gui_grid.py b/src/Mod/Draft/draftguitools/gui_grid.py index d74d0bfdef..835a98cd2d 100644 --- a/src/Mod/Draft/draftguitools/gui_grid.py +++ b/src/Mod/Draft/draftguitools/gui_grid.py @@ -34,7 +34,7 @@ from PySide.QtCore import QT_TRANSLATE_NOOP import FreeCADGui as Gui import draftguitools.gui_base as gui_base -from draftutils.translate import _tr +from draftutils.translate import translate class ToggleGrid(gui_base.GuiCommandSimplest): @@ -48,18 +48,15 @@ class ToggleGrid(gui_base.GuiCommandSimplest): """ def __init__(self): - super(ToggleGrid, self).__init__(name=_tr("Toggle grid")) + super(ToggleGrid, self).__init__(name=translate("draft","Toggle grid")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Toggles the Draft grid on and off." d = {'Pixmap': 'Draft_Grid', 'Accel': "G,R", - 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleGrid", - "Toggle grid"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleGrid", - _tip), + 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleGrid","Toggle grid"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleGrid","Toggles the Draft grid on and off."), 'CmdType': 'ForEdit'} return d diff --git a/src/Mod/Draft/draftguitools/gui_groups.py b/src/Mod/Draft/draftguitools/gui_groups.py index d580ce4e68..7e1039e450 100644 --- a/src/Mod/Draft/draftguitools/gui_groups.py +++ b/src/Mod/Draft/draftguitools/gui_groups.py @@ -44,7 +44,7 @@ import draftutils.utils as utils import draftutils.groups as groups import draftguitools.gui_base as gui_base -from draftutils.translate import _tr, translate +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -61,21 +61,16 @@ class AddToGroup(gui_base.GuiCommandNeedsSelection): """ def __init__(self): - super(AddToGroup, self).__init__(name=_tr("Add to group")) - self.ungroup = QT_TRANSLATE_NOOP("Draft_AddToGroup", - "Ungroup") + super(AddToGroup, self).__init__(name=translate("draft","Add to group")) + self.ungroup = QT_TRANSLATE_NOOP("Draft_AddToGroup","Ungroup") def GetResources(self): """Set icon, menu and tooltip.""" - _tooltip = ("Moves the selected objects to an existing group, " - "or removes them from any group.\n" - "Create a group first to use this tool.") + _tooltip = () d = {'Pixmap': 'Draft_AddToGroup', - 'MenuText': QT_TRANSLATE_NOOP("Draft_AddToGroup", - "Move to group")+"...", - 'ToolTip': QT_TRANSLATE_NOOP("Draft_AddToGroup", - _tooltip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_AddToGroup","Move to group")+"...", + 'ToolTip': QT_TRANSLATE_NOOP("Draft_AddToGroup","Moves the selected objects to an existing group, or removes them from any group.\nCreate a group first to use this tool.")} return d def Activated(self): @@ -161,24 +156,14 @@ class SelectGroup(gui_base.GuiCommandNeedsSelection): """ def __init__(self): - super(SelectGroup, self).__init__(name=_tr("Select group")) + super(SelectGroup, self).__init__(name=translate("draft","Select group")) def GetResources(self): """Set icon, menu and tooltip.""" - _tooltip = ("If the selection is a group, it selects all objects " - "that are inside this group, including those in " - "nested sub-groups.\n" - "\n" - "If the selection is a simple object inside a group, " - 'it will select the "brother" objects, that is,\n' - "those that are at the same level as this object, " - "including the upper group that contains them all.") d = {'Pixmap': 'Draft_SelectGroup', - 'MenuText': QT_TRANSLATE_NOOP("Draft_SelectGroup", - "Select group"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_SelectGroup", - _tooltip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_SelectGroup","Select group"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_SelectGroup","If the selection is a group, it selects all objects that are inside this group, including those in nested sub-groups.\n\nIf the selection is a simple object inside a group, it will select the "brother" objects, that is,\nthose that are at the same level as this object, including the upper group that contains them all.")} return d def Activated(self): @@ -244,15 +229,14 @@ class SetAutoGroup(gui_base.GuiCommandSimplest): """GuiCommand for the Draft_AutoGroup tool.""" def __init__(self): - super(SetAutoGroup, self).__init__(name=_tr("Autogroup")) + super(SetAutoGroup, self).__init__(name=translate("draft","Autogroup")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Select a group to add all Draft and Arch objects to." return {'Pixmap': 'Draft_AutoGroup', 'MenuText': QT_TRANSLATE_NOOP("Draft_AutoGroup", "Autogroup"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_AutoGroup", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_AutoGroup", "Select a group to add all Draft and Arch objects to.")} def Activated(self): """Execute when the command is called. @@ -349,18 +333,14 @@ class AddToConstruction(gui_base.GuiCommandSimplest): """ def __init__(self): - super(AddToConstruction, self).__init__(name=_tr("Add to construction group")) + super(AddToConstruction, self).__init__(name=translate("draft","Add to construction group")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Add to Construction group" - _tip = ("Adds the selected objects to the construction group,\n" - "and changes their appearance to the construction style.\n" - "It creates a construction group if it doesn't exist.") d = {'Pixmap': 'Draft_AddConstruction', - 'MenuText': QT_TRANSLATE_NOOP("Draft_AddConstruction", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_AddConstruction", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_AddConstruction", "Add to Construction group"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_AddConstruction", "Adds the selected objects to the construction group,\nand changes their appearance to the construction style.\nIt creates a construction group if it doesn't exist.")} return d def Activated(self): diff --git a/src/Mod/Draft/draftguitools/gui_heal.py b/src/Mod/Draft/draftguitools/gui_heal.py index 6849019dd5..e05c33bc04 100644 --- a/src/Mod/Draft/draftguitools/gui_heal.py +++ b/src/Mod/Draft/draftguitools/gui_heal.py @@ -35,7 +35,7 @@ import FreeCADGui as Gui import Draft import draftguitools.gui_base as gui_base -from draftutils.translate import _tr +from draftutils.translate import translate class Heal(gui_base.GuiCommandSimplest): @@ -48,20 +48,15 @@ class Heal(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Heal, self).__init__(name=_tr("Heal")) + super(Heal, self).__init__(name=translate("draft","Heal")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Heal faulty Draft objects saved with an earlier version " - "of the program.\n" - "If an object is selected it will try to heal that object " - "in particular,\n" - "otherwise it will try to heal all objects " - "in the active document.") + _tip = () return {'Pixmap': 'Draft_Heal', 'MenuText': QT_TRANSLATE_NOOP("Draft_Heal", "Heal"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Heal", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Heal", "Heal faulty Draft objects saved with an earlier version of the program.\nIf an object is selected it will try to heal that object in particular,\notherwise it will try to heal all objects in the active document.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_join.py b/src/Mod/Draft/draftguitools/gui_join.py index 62cfcb5919..ce2b6a4119 100644 --- a/src/Mod/Draft/draftguitools/gui_join.py +++ b/src/Mod/Draft/draftguitools/gui_join.py @@ -49,7 +49,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -60,19 +60,15 @@ class Join(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Joins the selected lines or polylines " - "into a single object.\n" - "The lines must share a common point at the start " - "or at the end for the operation to succeed.") return {'Pixmap': 'Draft_Join', 'Accel': "J, O", 'MenuText': QT_TRANSLATE_NOOP("Draft_Join", "Join"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Join", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Join", "Joins the selected lines or polylines into a single object.\nThe lines must share a common point at the start or at the end for the operation to succeed.")} def Activated(self): """Execute when the command is called.""" - super(Join, self).Activated(name=_tr("Join")) + super(Join, self).Activated(name=translate("draft","Join")) if not self.ui: return if not Gui.Selection.getSelection(): @@ -111,7 +107,7 @@ class Join(gui_base_original.Modifier): labels.append(obj.Label) labels = ", ".join(labels) - _msg(_tr("Selection:") + " {}".format(labels)) + _msg(translate("draft","Selection:") + " {}".format(labels)) Gui.addCommand('Draft_Join', Join()) diff --git a/src/Mod/Draft/draftguitools/gui_labels.py b/src/Mod/Draft/draftguitools/gui_labels.py index d3d0e6e8f2..0e6145a71c 100644 --- a/src/Mod/Draft/draftguitools/gui_labels.py +++ b/src/Mod/Draft/draftguitools/gui_labels.py @@ -58,25 +58,11 @@ class Label(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a label, " - "optionally attached to a selected object or subelement.\n" - "\n" - "First select a vertex, an edge, or a face of an object, " - "then call this command,\n" - "and then set the position of the leader line " - "and the textual label.\n" - "The label will be able to display information " - "about this object, and about the selected subelement,\n" - "if any.\n" - "\n" - "If many objects or many subelements are selected, " - "only the first one in each case\n" - "will be used to provide information to the label.") return {'Pixmap': 'Draft_Label', 'Accel': "D, L", 'MenuText': QT_TRANSLATE_NOOP("Draft_Label", "Label"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Label", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Label", "Creates a label, optionally attached to a selected object or subelement.\n\nFirst select a vertex, an edge, or a face of an object, then call this command,\nand then set the position of the leader line and the textual label.\nThe label will be able to display information about this object, and about the selected subelement,\nif any.\n\nIf many objects or many subelements are selected, only the first one in each case\nwill be used to provide information to the label.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_layers.py b/src/Mod/Draft/draftguitools/gui_layers.py index aff58f1d0b..ab66fa7347 100644 --- a/src/Mod/Draft/draftguitools/gui_layers.py +++ b/src/Mod/Draft/draftguitools/gui_layers.py @@ -34,7 +34,7 @@ import FreeCADGui as Gui import Draft_rc import draftguitools.gui_base as gui_base -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) bool(Draft_rc.__name__) @@ -44,18 +44,13 @@ class Layer(gui_base.GuiCommandSimplest): """GuiCommand to create a Layer object in the document.""" def __init__(self): - super(Layer, self).__init__(name=_tr("Layer")) + super(Layer, self).__init__(name=translate("draft","Layer")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = QT_TRANSLATE_NOOP("Draft_Layer", - "Adds a layer to the document.\n" - "Objects added to this layer can share " - "the same visual properties such as " - "line color, line width, and shape color.") return {'Pixmap': 'Draft_Layer', 'MenuText': QT_TRANSLATE_NOOP("Draft_Layer", "Layer"), - 'ToolTip': _tip} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Layer", "Adds a layer to the document.\nObjects added to this layer can share the same visual properties such as line color, line width, and shape color.")} def Activated(self): """Execute when the command is called. diff --git a/src/Mod/Draft/draftguitools/gui_line_add_delete.py b/src/Mod/Draft/draftguitools/gui_line_add_delete.py index 479bbee781..53aec152e2 100644 --- a/src/Mod/Draft/draftguitools/gui_line_add_delete.py +++ b/src/Mod/Draft/draftguitools/gui_line_add_delete.py @@ -52,12 +52,10 @@ class AddPoint(DraftTools.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Add point" - _tip = "Adds a point to an existing Wire or B-spline." return {'Pixmap': 'Draft_AddPoint', - 'MenuText': QT_TRANSLATE_NOOP("Draft_AddPoint", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_AddPoint", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_AddPoint", "Add point"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_AddPoint", "Adds a point to an existing Wire or B-spline.")} def IsActive(self): """Return True when there is selection and the command is active.""" @@ -86,12 +84,10 @@ class DelPoint(DraftTools.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Remove point" - _tip = "Removes a point from an existing Wire or B-spline." return {'Pixmap': 'Draft_DelPoint', - 'MenuText': QT_TRANSLATE_NOOP("Draft_DelPoint", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_DelPoint", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_DelPoint", "Remove point"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_DelPoint", "Removes a point from an existing Wire or B-spline.")} def IsActive(self): """Return True when there is selection and the command is active.""" diff --git a/src/Mod/Draft/draftguitools/gui_lineops.py b/src/Mod/Draft/draftguitools/gui_lineops.py index eeb5b41933..afa9f7722b 100644 --- a/src/Mod/Draft/draftguitools/gui_lineops.py +++ b/src/Mod/Draft/draftguitools/gui_lineops.py @@ -41,7 +41,7 @@ import Draft_rc import draftguitools.gui_base as gui_base from draftutils.messages import _msg -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -70,7 +70,7 @@ class LineAction(gui_base.GuiCommandSimplest): if hasattr(App, "activeDraftCommand"): _command = App.activeDraftCommand else: - _msg(_tr("No active command.")) + _msg(translate("draft","No active command.")) return if (_command is not None @@ -89,15 +89,14 @@ class FinishLine(LineAction): """GuiCommand to finish any running line drawing operation.""" def __init__(self): - super(FinishLine, self).__init__(name=_tr("Finish line")) + super(FinishLine, self).__init__(name=translate("draft","Finish line")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Finishes a line without closing it." d = {'Pixmap': 'Draft_Finish', 'MenuText': QT_TRANSLATE_NOOP("Draft_FinishLine", "Finish line"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_FinishLine", _tip), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_FinishLine", "Finishes a line without closing it."), 'CmdType': 'ForEdit'} return d @@ -116,15 +115,14 @@ class CloseLine(LineAction): """GuiCommand to close the line being drawn and finish the operation.""" def __init__(self): - super(CloseLine, self).__init__(name=_tr("Close line")) + super(CloseLine, self).__init__(name=translate("draft","Close line")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Closes the line being drawn, and finishes the operation." d = {'Pixmap': 'Draft_Lock', 'MenuText': QT_TRANSLATE_NOOP("Draft_CloseLine", "Close Line"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_CloseLine", _tip), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_CloseLine", "Closes the line being drawn, and finishes the operation."), 'CmdType': 'ForEdit'} return d @@ -143,16 +141,15 @@ class UndoLine(LineAction): """GuiCommand to undo the last drawn segment of a line.""" def __init__(self): - super(UndoLine, self).__init__(name=_tr("Undo line")) + super(UndoLine, self).__init__(name=translate("draft","Undo line")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Undoes the last drawn segment of the line being drawn." d = {'Pixmap': 'Draft_Rotate', 'MenuText': QT_TRANSLATE_NOOP("Draft_UndoLine", "Undo last segment"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_UndoLine", _tip), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_UndoLine", "Undoes the last drawn segment of the line being drawn."), 'CmdType': 'ForEdit'} return d diff --git a/src/Mod/Draft/draftguitools/gui_lines.py b/src/Mod/Draft/draftguitools/gui_lines.py index eba740fb45..f2be94a84a 100644 --- a/src/Mod/Draft/draftguitools/gui_lines.py +++ b/src/Mod/Draft/draftguitools/gui_lines.py @@ -58,12 +58,11 @@ class Line(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Creates a 2-point line. CTRL to snap, SHIFT to constrain." return {'Pixmap': 'Draft_Line', 'Accel': "L,I", 'MenuText': QT_TRANSLATE_NOOP("Draft_Line", "Line"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Line", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Line", "Creates a 2-point line. CTRL to snap, SHIFT to constrain.")} def Activated(self, name=translate("draft", "Line")): """Execute when the command is called.""" @@ -307,13 +306,11 @@ class Wire(Line): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a multiple-points line (polyline). " - "CTRL to snap, SHIFT to constrain.") return {'Pixmap': 'Draft_Wire', 'Accel': "P, L", 'MenuText': QT_TRANSLATE_NOOP("Draft_Wire", "Polyline"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Wire", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Wire", "Creates a multiple-points line (polyline). CTRL to snap, SHIFT to constrain.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_lineslope.py b/src/Mod/Draft/draftguitools/gui_lineslope.py index 3ce7f31329..443b2a1d02 100644 --- a/src/Mod/Draft/draftguitools/gui_lineslope.py +++ b/src/Mod/Draft/draftguitools/gui_lineslope.py @@ -42,7 +42,7 @@ import Draft_rc import draftutils.utils as utils import draftguitools.gui_base as gui_base -from draftutils.translate import _tr, translate +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -61,23 +61,14 @@ class LineSlope(gui_base.GuiCommandNeedsSelection): """ def __init__(self): - super(LineSlope, self).__init__(name=_tr("Change slope")) + super(LineSlope, self).__init__(name=translate("draft","Change slope")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Set slope" - _tip = ("Sets the slope of the selected line " - "by changing the value of the Z value of one of its points.\n" - "If a polyline is selected, it will apply the slope " - "transformation to each of its segments.\n\n" - "The slope will always change the Z value, therefore " - "this command only works well for\n" - "straight Draft lines that are drawn in the XY plane. " - "Selected objects that aren't single lines will be ignored.") return {'Pixmap': 'Draft_Slope', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Slope", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Slope", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Slope", "Set slope"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Slope", "Sets the slope of the selected line by changing the value of the Z value of one of its points.\nIf a polyline is selected, it will apply the slope transformation to each of its segments.\n\nThe slope will always change the Z value, therefore this command only works well for\nstraight Draft lines that are drawn in the XY plane. Selected objects that aren't single lines will be ignored.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_mirror.py b/src/Mod/Draft/draftguitools/gui_mirror.py index 7691a7df66..18afa9c9f7 100644 --- a/src/Mod/Draft/draftguitools/gui_mirror.py +++ b/src/Mod/Draft/draftguitools/gui_mirror.py @@ -57,13 +57,11 @@ class Mirror(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Mirrors the selected objects along a line " - "defined by two points.") return {'Pixmap': 'Draft_Mirror', 'Accel': "M, I", 'MenuText': QT_TRANSLATE_NOOP("Draft_Mirror", "Mirror"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Mirror", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Mirror", "Mirrors the selected objects along a line defined by two points.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_move.py b/src/Mod/Draft/draftguitools/gui_move.py index 8c7458bb27..ccccbd5876 100644 --- a/src/Mod/Draft/draftguitools/gui_move.py +++ b/src/Mod/Draft/draftguitools/gui_move.py @@ -57,16 +57,11 @@ class Move(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Moves the selected objects from one base point " - "to another point.\n" - 'If the "copy" option is active, it will create ' - "displaced copies.\n" - "CTRL to snap, SHIFT to constrain.") return {'Pixmap': 'Draft_Move', 'Accel': "M, V", 'MenuText': QT_TRANSLATE_NOOP("Draft_Move", "Move"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Move", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Move", "Moves the selected objects from one base point to another point.\nIf the \"copy\" option is active, it will create displaced copies.\nCTRL to snap, SHIFT to constrain.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_offset.py b/src/Mod/Draft/draftguitools/gui_offset.py index 86e21b044d..50f8c928f4 100644 --- a/src/Mod/Draft/draftguitools/gui_offset.py +++ b/src/Mod/Draft/draftguitools/gui_offset.py @@ -46,7 +46,7 @@ import draftguitools.gui_tool_utils as gui_tool_utils import draftguitools.gui_trackers as trackers from draftutils.messages import _msg, _wrn, _err -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -57,20 +57,16 @@ class Offset(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Offsets of the selected object.\n" - "It can also create an offset copy of the original object.\n" - "CTRL to snap, SHIFT to constrain. " - "Hold ALT and click to create a copy with each click.") return {'Pixmap': 'Draft_Offset', 'Accel': "O, S", 'MenuText': QT_TRANSLATE_NOOP("Draft_Offset", "Offset"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Offset", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Offset", "Offsets of the selected object.\nIt can also create an offset copy of the original object.\nCTRL to snap, SHIFT to constrain. Hold ALT and click to create a copy with each click.")} def Activated(self): """Execute when the command is called.""" self.running = False - super(Offset, self).Activated(name=_tr("Offset")) + super(Offset, self).Activated(name=translate("draft","Offset")) self.ghost = None self.linetrack = None self.arctrack = None @@ -327,9 +323,7 @@ class Offset(gui_base_original.Modifier): self.finish() else: _err(translate("Draft", - "Offset direction is not defined. " - "Please move the mouse on either side " - "of the object first to indicate a direction")) + "Offset direction is not defined. Please move the mouse on either side of the object first to indicate a direction")) Gui.addCommand('Draft_Offset', Offset()) diff --git a/src/Mod/Draft/draftguitools/gui_orthoarray.py b/src/Mod/Draft/draftguitools/gui_orthoarray.py index 19ba415c8c..c85e737d65 100644 --- a/src/Mod/Draft/draftguitools/gui_orthoarray.py +++ b/src/Mod/Draft/draftguitools/gui_orthoarray.py @@ -37,7 +37,7 @@ import Draft_rc # include resources, icons, ui files import draftutils.todo as todo from draftutils.messages import _msg, _log -from draftutils.translate import _tr +from draftutils.translate import translate from draftguitools import gui_base from drafttaskpanels import task_orthoarray @@ -61,17 +61,10 @@ class OrthoArray(gui_base.GuiCommandBase): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates copies of the selected object, " - "and places the copies in an orthogonal pattern,\n" - "meaning the copies follow the specified direction " - "in the X, Y, Z axes.\n" - "\n" - "The array can be turned into a polar or a circular array " - "by changing its type.") d = {'Pixmap': 'Draft_Array', 'MenuText': QT_TRANSLATE_NOOP("Draft", "Array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft", "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.")} return d def Activated(self): @@ -80,9 +73,9 @@ class OrthoArray(gui_base.GuiCommandBase): We add callbacks that connect the 3D view with the widgets of the task panel. """ - _log("GuiCommand: {}".format(_tr(self.command_name))) - _msg("{}".format(16*"-")) - _msg("GuiCommand: {}".format(_tr(self.command_name))) + _log("GuiCommand: {}".format(_self.command_name)) + #_msg("{}".format(16*"-")) + #_msg("GuiCommand: {}".format(self.command_name)) # self.location = coin.SoLocation2Event.getClassTypeId() self.mouse_event = coin.SoMouseButtonEvent.getClassTypeId() diff --git a/src/Mod/Draft/draftguitools/gui_patharray.py b/src/Mod/Draft/draftguitools/gui_patharray.py index 15a3d32448..3c061832ef 100644 --- a/src/Mod/Draft/draftguitools/gui_patharray.py +++ b/src/Mod/Draft/draftguitools/gui_patharray.py @@ -45,7 +45,7 @@ import DraftVecUtils import draftguitools.gui_base_original as gui_base_original from draftutils.messages import _err -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -68,18 +68,12 @@ class PathArray(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Path array" - _tip = ("Creates copies of the selected object " - "along a selected path.\n" - "First select the object, and then select the path.\n" - "The path can be a polyline, B-spline, Bezier curve, " - "or even edges from other objects.") return {'Pixmap': 'Draft_PathArray', - 'MenuText': QT_TRANSLATE_NOOP("Draft_PathArray", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathArray", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_PathArray", "Path array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathArray", "Creates copies of the selected object along a selected path.\nFirst select the object, and then select the path.\nThe path can be a polyline, B-spline, Bezier curve, or even edges from other objects.")} - def Activated(self, name=_tr("Path array")): + def Activated(self, name=translate("draft","Path array")): """Execute when the command is called.""" super(PathArray, self).Activated(name=name) self.name = name @@ -105,9 +99,7 @@ class PathArray(gui_base_original.Modifier): """Proceed with the command if one object was selected.""" sel = Gui.Selection.getSelectionEx() if len(sel) != 2: - _err(_tr("Please select exactly two objects, " - "the base object and the path object, " - "before calling this command.")) + _err(translate("draft","Please select exactly two objects, the base object and the path object, before calling this command.")) else: base_object = sel[0].Object path_object = sel[1].Object @@ -148,7 +140,7 @@ class PathArray(gui_base_original.Modifier): _cmd_list = ["_obj_ = " + _cmd, "Draft.autogroup(_obj_)", "App.ActiveDocument.recompute()"] - self.commit(_tr(self.name), _cmd_list) + self.commit(translate("draft","Path array"), _cmd_list) # Commit the transaction and execute the commands # through the parent class @@ -166,19 +158,14 @@ class PathLinkArray(PathArray): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Path Link array" - _tip = ("Like the PathArray tool, but creates a 'Link array' " - "instead.\n" - "A 'Link array' is more efficient when handling many copies " - "but the 'Fuse' option cannot be used.") return {'Pixmap': 'Draft_PathLinkArray', - 'MenuText': QT_TRANSLATE_NOOP("Draft_PathLinkArray", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathLinkArray", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_PathLinkArray", "Path Link array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathLinkArray", "Like the PathArray tool, but creates a 'Link array' instead.\nA 'Link array' is more efficient when handling many copies but the 'Fuse' option cannot be used.")} def Activated(self): """Execute when the command is called.""" - super(PathLinkArray, self).Activated(name=_tr("Path link array")) + super(PathLinkArray, self).Activated(name=translate("draft","Path link array")) Gui.addCommand('Draft_PathLinkArray', PathLinkArray()) diff --git a/src/Mod/Draft/draftguitools/gui_pathtwistedarray.py b/src/Mod/Draft/draftguitools/gui_pathtwistedarray.py index daf0e81660..27d0943a7b 100644 --- a/src/Mod/Draft/draftguitools/gui_pathtwistedarray.py +++ b/src/Mod/Draft/draftguitools/gui_pathtwistedarray.py @@ -38,7 +38,7 @@ import Draft_rc import draftguitools.gui_base_original as gui_base_original from draftutils.messages import _err -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -61,18 +61,12 @@ class PathTwistedArray(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Path twisted array" - _tip = ("Creates copies of the selected object " - "along a selected path, and twists the copies.\n" - "First select the object, and then select the path.\n" - "The path can be a polyline, B-spline, Bezier curve, " - "or even edges from other objects.") return {'Pixmap': 'Draft_PathTwistedArray', - 'MenuText': QT_TRANSLATE_NOOP("Draft_PathTwistedArray", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathTwistedArray", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_PathTwistedArray", "Path twisted array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathTwistedArray", "Creates copies of the selected object along a selected path, and twists the copies.\nFirst select the object, and then select the path.\nThe path can be a polyline, B-spline, Bezier curve, or even edges from other objects.")} - def Activated(self, name=_tr("Path twisted array")): + def Activated(self, name=translate("draft","Path twisted array")): """Execute when the command is called.""" super(PathTwistedArray, self).Activated(name=name) self.name = name @@ -82,9 +76,7 @@ class PathTwistedArray(gui_base_original.Modifier): """Proceed with the command if one object was selected.""" sel = Gui.Selection.getSelectionEx() if len(sel) != 2: - _err(_tr("Please select exactly two objects, " - "the base object and the path object, " - "before calling this command.")) + _err(translate("draft","Please select exactly two objects, the base object and the path object, before calling this command.")) else: base_object = sel[0].Object path_object = sel[1].Object @@ -106,7 +98,7 @@ class PathTwistedArray(gui_base_original.Modifier): _cmd_list = ["_obj_ = " + _cmd, "Draft.autogroup(_obj_)", "App.ActiveDocument.recompute()"] - self.commit(_tr(self.name), _cmd_list) + self.commit(translate("draft","Path twisted array"), _cmd_list) # Commit the transaction and execute the commands # through the parent class @@ -124,22 +116,15 @@ class PathTwistedLinkArray(PathTwistedArray): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Path twisted Link array" - _tip = ("Like the PathTwistedArray tool, but creates a 'Link array' " - "instead.\n" - "A 'Link array' is more efficient when handling many copies " - "but the 'Fuse' option cannot be used.") return {'Pixmap': 'Draft_PathTwistedLinkArray', - 'MenuText': QT_TRANSLATE_NOOP("Draft_PathTwistedLinkArray", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathTwistedLinkArray", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_PathTwistedLinkArray","Path twisted Link array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_PathTwistedLinkArray","Like the PathTwistedArray tool, but creates a 'Link array' instead.\nA 'Link array' is more efficient when handling many copies but the 'Fuse' option cannot be used.")} def Activated(self): """Execute when the command is called.""" super(PathTwistedLinkArray, - self).Activated(name=_tr("Path twisted link array")) + self).Activated(name=translate("draft","Path twisted link array")) Gui.addCommand('Draft_PathTwistedLinkArray', PathTwistedLinkArray()) diff --git a/src/Mod/Draft/draftguitools/gui_planeproxy.py b/src/Mod/Draft/draftguitools/gui_planeproxy.py index f3df16d97c..4615819136 100644 --- a/src/Mod/Draft/draftguitools/gui_planeproxy.py +++ b/src/Mod/Draft/draftguitools/gui_planeproxy.py @@ -45,17 +45,10 @@ class Draft_WorkingPlaneProxy: def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Create working plane proxy" - _tip = ("Creates a proxy object from the current working plane.\n" - "Once the object is created double click it in the tree view " - "to restore the camera position and objects' visibilities.\n" - "Then you can use it to save a different camera position " - "and objects' states any time you need.") + d = {'Pixmap': 'Draft_PlaneProxy', - 'MenuText': QT_TRANSLATE_NOOP("Draft_SetWorkingPlaneProxy", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_SetWorkingPlaneProxy", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_SetWorkingPlaneProxy","Create working plane proxy"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_SetWorkingPlaneProxy","Creates a proxy object from the current working plane.\nOnce the object is created double click it in the tree view to restore the camera position and objects' visibilities.\nThen you can use it to save a different camera position and objects' states any time you need.")} return d def IsActive(self): diff --git a/src/Mod/Draft/draftguitools/gui_pointarray.py b/src/Mod/Draft/draftguitools/gui_pointarray.py index 7057afeb6c..c6488f623c 100644 --- a/src/Mod/Draft/draftguitools/gui_pointarray.py +++ b/src/Mod/Draft/draftguitools/gui_pointarray.py @@ -49,7 +49,7 @@ import Draft_rc import draftguitools.gui_base_original as gui_base_original from draftutils.messages import _err -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -71,28 +71,15 @@ class PointArray(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Point array" - _tip = ("Creates copies of the selected object, " - "and places the copies at the position of various points.\n" - "\n" - "The points need to be grouped under a compound of points " - "before using this tool.\n" - "To create this compound, select various points " - "and then use the Part Compound tool,\n" - "or use the Draft Upgrade tool to create a 'Block', " - "or create a Sketch and add simple points to it.\n" - "\n" - "Select the base object, and then select the compound " - "or the sketch to create the point array.") return {'Pixmap': 'Draft_PointArray', - 'MenuText': QT_TRANSLATE_NOOP("Draft_PointArray", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_PointArray", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_PointArray", "Point array"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_PointArray", "Creates copies of the selected object, and places the copies at the position of various points.\n\nThe points need to be grouped under a compound of points before using this tool.\nTo create this compound, select various points and then use the Part Compound tool,\nor use the Draft Upgrade tool to create a 'Block', or create a Sketch and add simple points to it.\n\nSelect the base object, and then select the compound or the sketch to create the point array.")} def Activated(self, name="Point array"): """Execute when the command is called.""" self.name = name - super(PointArray, self).Activated(name=_tr(self.name)) + super(PointArray, self).Activated(name=translate("draft","Point array")) # This was deactivated because it doesn't work correctly; # the selection needs to be made on two objects, but currently # it only selects one. @@ -115,9 +102,7 @@ class PointArray(gui_base_original.Modifier): """Proceed with the command if one object was selected.""" sel = Gui.Selection.getSelectionEx() if len(sel) != 2: - _err(_tr("Please select exactly two objects, " - "the base object and the point object, " - "before calling this command.")) + _err(translate("draft","Please select exactly two objects, the base object and the point object, before calling this command.")) else: base_object = sel[0].Object point_object = sel[1].Object @@ -135,7 +120,7 @@ class PointArray(gui_base_original.Modifier): _cmd_list = ["_obj_ = " + _cmd, "Draft.autogroup(_obj_)", "App.ActiveDocument.recompute()"] - self.commit(_tr(self.name), _cmd_list) + self.commit(translate("draft","Point array"), _cmd_list) # Commit the transaction and execute the commands # through the parent class @@ -152,12 +137,10 @@ class PointLinkArray(PointArray): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Like the PointArray tool, but creates a 'Point link array' instead.\n" - "A 'Point link array' is more efficient when handling many copies.") return {'Pixmap': 'Draft_PointLinkArray', 'MenuText': QT_TRANSLATE_NOOP("Draft_PointLinkArray", "PointLinkArray"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_PointLinkArray", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_PointLinkArray", "Like the PointArray tool, but creates a 'Point link array' instead.\nA 'Point link array' is more efficient when handling many copies.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_points.py b/src/Mod/Draft/draftguitools/gui_points.py index e6be1e317f..7f67ef614b 100644 --- a/src/Mod/Draft/draftguitools/gui_points.py +++ b/src/Mod/Draft/draftguitools/gui_points.py @@ -46,7 +46,7 @@ import draftutils.gui_utils as gui_utils import draftguitools.gui_base_original as gui_base_original import draftutils.todo as todo -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -57,15 +57,14 @@ class Point(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Creates a point object. Click anywhere on the 3D view." return {'Pixmap': 'Draft_Point', 'MenuText': QT_TRANSLATE_NOOP("Draft_Point", "Point"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Point", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Point", "Creates a point object. Click anywhere on the 3D view.")} def Activated(self): """Execute when the command is called.""" - super(Point, self).Activated(name=_tr("Point")) + super(Point, self).Activated(name=translate("draft","Point")) self.view = gui_utils.get3DView() self.stack = [] rot = self.view.getCameraNode().getField("orientation").getValue() diff --git a/src/Mod/Draft/draftguitools/gui_polararray.py b/src/Mod/Draft/draftguitools/gui_polararray.py index 0e2d465d34..6ed9e49dae 100644 --- a/src/Mod/Draft/draftguitools/gui_polararray.py +++ b/src/Mod/Draft/draftguitools/gui_polararray.py @@ -37,7 +37,7 @@ import Draft_rc # include resources, icons, ui files import draftutils.todo as todo from draftutils.messages import _msg, _log -from draftutils.translate import _tr +from draftutils.translate import translate from draftguitools import gui_base from drafttaskpanels import task_polararray @@ -61,16 +61,10 @@ class PolarArray(gui_base.GuiCommandBase): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates copies of the selected object, " - "and places the copies in a polar pattern\n" - "defined by a center of rotation and its angle.\n" - "\n" - "The array can be turned into an orthogonal " - "or a circular array by changing its type.") d = {'Pixmap': 'Draft_PolarArray', 'MenuText': QT_TRANSLATE_NOOP("Draft", "Polar array"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft", "Creates copies of the selected object, and places the copies in a polar pattern\ndefined by a center of rotation and its angle.\n\nThe array can be turned into an orthogonal or a circular array by changing its type.")} return d def Activated(self): @@ -79,9 +73,9 @@ class PolarArray(gui_base.GuiCommandBase): We add callbacks that connect the 3D view with the widgets of the task panel. """ - _log("GuiCommand: {}".format(_tr(self.command_name))) - _msg("{}".format(16*"-")) - _msg("GuiCommand: {}".format(_tr(self.command_name))) + _log("GuiCommand: {}".format(self.command_name)) + #_msg("{}".format(16*"-")) + #_msg("GuiCommand: {}".format(self.command_name)) self.location = coin.SoLocation2Event.getClassTypeId() self.mouse_event = coin.SoMouseButtonEvent.getClassTypeId() diff --git a/src/Mod/Draft/draftguitools/gui_polygons.py b/src/Mod/Draft/draftguitools/gui_polygons.py index 3011c7cf5b..5a8daa51e0 100644 --- a/src/Mod/Draft/draftguitools/gui_polygons.py +++ b/src/Mod/Draft/draftguitools/gui_polygons.py @@ -51,15 +51,11 @@ class Polygon(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a regular polygon (triangle, square, " - "pentagon, ...), by defining the number of sides " - "and the circumscribed radius.\n" - "CTRL to snap, SHIFT to constrain") return {'Pixmap': 'Draft_Polygon', 'Accel': "P, G", 'MenuText': QT_TRANSLATE_NOOP("Draft_Polygon", "Polygon"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Polygon", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Polygon", "Creates a regular polygon (triangle, square, pentagon, ...), by defining the number of sides and the circumscribed radius.\nCTRL to snap, SHIFT to constrain")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_rectangles.py b/src/Mod/Draft/draftguitools/gui_rectangles.py index aff2978189..f4e4b4a312 100644 --- a/src/Mod/Draft/draftguitools/gui_rectangles.py +++ b/src/Mod/Draft/draftguitools/gui_rectangles.py @@ -48,12 +48,11 @@ class Rectangle(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Creates a 2-point rectangle. CTRL to snap." return {'Pixmap': 'Draft_Rectangle', 'Accel': "R, E", 'MenuText': QT_TRANSLATE_NOOP("Draft_Rectangle", "Rectangle"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Rectangle", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Rectangle", "Creates a 2-point rectangle. CTRL to snap.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_rotate.py b/src/Mod/Draft/draftguitools/gui_rotate.py index 95286774a1..0f55cc5449 100644 --- a/src/Mod/Draft/draftguitools/gui_rotate.py +++ b/src/Mod/Draft/draftguitools/gui_rotate.py @@ -44,7 +44,7 @@ import draftguitools.gui_trackers as trackers from FreeCAD import Units as U from draftutils.messages import _msg, _err -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -55,22 +55,16 @@ class Rotate(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Rotates the selected objects. " - "Choose the center of rotation, then the initial angle, " - "and then the final angle.\n" - 'If the "copy" option is active, it will create ' - "rotated copies.\n" - "CTRL to snap, SHIFT to constrain. " - "Hold ALT and click to create a copy with each click.") + _tip = () return {'Pixmap': 'Draft_Rotate', 'Accel': "R, O", 'MenuText': QT_TRANSLATE_NOOP("Draft_Rotate", "Rotate"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Rotate", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Rotate", "Rotates the selected objects. Choose the center of rotation, then the initial angle, and then the final angle.\nIf the \"copy\" option is active, it will create rotated copies.\nCTRL to snap, SHIFT to constrain. Hold ALT and click to create a copy with each click.")} def Activated(self): """Execute when the command is called.""" - super(Rotate, self).Activated(name=_tr("Rotate")) + super(Rotate, self).Activated(name=translate("draft","Rotate")) if not self.ui: return self.ghosts = [] @@ -199,8 +193,7 @@ class Rotate(gui_base_original.Modifier): self.ui.radiusValue.setText(U.Quantity(0, U.Angle).UserString) self.ui.hasFill.hide() self.ui.labelRadius.setText(translate("draft", "Base angle")) - _tip = "The base angle you wish to start the rotation from" - self.ui.radiusValue.setToolTip(translate("draft", _tip)) + self.ui.radiusValue.setToolTip(translate("draft", "The base angle you wish to start the rotation from")) self.arctrack.setCenter(self.center) for ghost in self.ghosts: ghost.center(self.center) @@ -212,9 +205,7 @@ class Rotate(gui_base_original.Modifier): def set_start_point(self): """Set the starting point of the rotation.""" self.ui.labelRadius.setText(translate("draft", "Rotation")) - _tip = ("The amount of rotation you wish to perform.\n" - "The final angle will be the base angle plus this amount.") - self.ui.radiusValue.setToolTip(translate("draft", _tip)) + self.ui.radiusValue.setToolTip(translate("draft", "The amount of rotation you wish to perform.\nThe final angle will be the base angle plus this amount.")) self.rad = DraftVecUtils.dist(self.point, self.center) self.arctrack.on() self.arctrack.setStartPoint(self.point) @@ -397,8 +388,7 @@ class Rotate(gui_base_original.Modifier): self.ui.radiusUi() self.ui.hasFill.hide() self.ui.labelRadius.setText(translate("draft", "Base angle")) - _tip = "The base angle you wish to start the rotation from" - self.ui.radiusValue.setToolTip(translate("draft", _tip)) + self.ui.radiusValue.setToolTip(translate("draft", "The base angle you wish to start the rotation from")) self.ui.radiusValue.setText(U.Quantity(0, U.Angle).UserString) self.step = 1 _msg(translate("draft", "Pick base angle")) @@ -411,10 +401,7 @@ class Rotate(gui_base_original.Modifier): """ if self.step == 1: self.ui.labelRadius.setText(translate("draft", "Rotation")) - _tip = ("The amount of rotation you wish to perform.\n" - "The final angle will be the base angle " - "plus this amount.") - self.ui.radiusValue.setToolTip(translate("draft", _tip)) + self.ui.radiusValue.setToolTip(translate("draft", "The amount of rotation you wish to perform.\nThe final angle will be the base angle plus this amount.")) self.ui.radiusValue.setText(U.Quantity(0, U.Angle).UserString) self.firstangle = math.radians(rad) self.arctrack.setStartAngle(self.firstangle) diff --git a/src/Mod/Draft/draftguitools/gui_scale.py b/src/Mod/Draft/draftguitools/gui_scale.py index 650c4646c0..b4b689733a 100644 --- a/src/Mod/Draft/draftguitools/gui_scale.py +++ b/src/Mod/Draft/draftguitools/gui_scale.py @@ -65,13 +65,11 @@ class Scale(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Scales the selected objects from a base point.\n" - "CTRL to snap, SHIFT to constrain, ALT to copy.") return {'Pixmap': 'Draft_Scale', 'Accel': "S, C", 'MenuText': QT_TRANSLATE_NOOP("Draft_Scale", "Scale"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Scale", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Scale", "Scales the selected objects from a base point.\nCTRL to snap, SHIFT to constrain, ALT to copy.")} def Activated(self): """Execute when the command is called.""" @@ -337,9 +335,7 @@ class Scale(gui_base_original.Modifier): else: m = translate("draft", "Unable to scale objects: ") m += ", ".join([o.Label for o in bads]) - m += " - " + translate("draft", - "This object type cannot be scaled " - "directly. Please use the clone method.") + m += " - " + translate("draft","This object type cannot be scaled directly. Please use the clone method.") _err(m) if goods: _doc = 'FreeCAD.ActiveDocument.' diff --git a/src/Mod/Draft/draftguitools/gui_selectplane.py b/src/Mod/Draft/draftguitools/gui_selectplane.py index 6037046223..0f02e484c3 100644 --- a/src/Mod/Draft/draftguitools/gui_selectplane.py +++ b/src/Mod/Draft/draftguitools/gui_selectplane.py @@ -60,14 +60,10 @@ class Draft_SelectPlane: def GetResources(self): """Set icon, menu and tooltip.""" - _msg = ("Select the face of solid body to create a working plane " - "on which to sketch Draft objects.\n" - "You may also select a three vertices or " - "a Working Plane Proxy.") d = {'Pixmap': 'Draft_SelectPlane', 'Accel': "W, P", 'MenuText': QT_TRANSLATE_NOOP("Draft_SelectPlane", "SelectPlane"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_SelectPlane", _msg)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_SelectPlane", "Select the face of solid body to create a working plane on which to sketch Draft objects.\nYou may also select a three vertices or a Working Plane Proxy.")} return d def IsActive(self): @@ -89,8 +85,7 @@ class Draft_SelectPlane: p = FreeCAD.DraftWorkingPlane self.states.append([p.u, p.v, p.axis, p.position]) - m = translate("draft", "Pick a face, 3 vertices " - "or a WP Proxy to define the drawing plane") + m = translate("draft", "Pick a face, 3 vertices or a WP Proxy to define the drawing plane") _msg(m) # Create task panel diff --git a/src/Mod/Draft/draftguitools/gui_shape2dview.py b/src/Mod/Draft/draftguitools/gui_shape2dview.py index fca56f6af7..80cacece0a 100644 --- a/src/Mod/Draft/draftguitools/gui_shape2dview.py +++ b/src/Mod/Draft/draftguitools/gui_shape2dview.py @@ -43,7 +43,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -54,23 +54,16 @@ class Shape2DView(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Shape 2D view" - _tip = ("Creates a 2D projection of the selected objects " - "on the XY plane.\n" - "The initial projection direction is the negative " - "of the current active view direction.\n" - "You can select individual faces to project, or " - "the entire solid, and also include hidden lines.\n" - "These projections can be used to create technical " - "drawings with the TechDraw Workbench.") + _menu = + _tip = () return {'Pixmap': 'Draft_2DShapeView', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Shape2DView", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Shape2DView", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Shape2DView", "Shape 2D view"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Shape2DView", "Creates a 2D projection of the selected objects on the XY plane.\nThe initial projection direction is the negative of the current active view direction.\nYou can select individual faces to project, or the entire solid, and also include hidden lines.\nThese projections can be used to create technical drawings with the TechDraw Workbench.")} def Activated(self): """Execute when the command is called.""" - super(Shape2DView, self).Activated(name=_tr("Project 2D view")) + super(Shape2DView, self).Activated(name=translate("draft","Project 2D view")) if not Gui.Selection.getSelection(): if self.ui: self.ui.selectUi() diff --git a/src/Mod/Draft/draftguitools/gui_shapestrings.py b/src/Mod/Draft/draftguitools/gui_shapestrings.py index 2d92c48c97..e1bf33abed 100644 --- a/src/Mod/Draft/draftguitools/gui_shapestrings.py +++ b/src/Mod/Draft/draftguitools/gui_shapestrings.py @@ -62,16 +62,13 @@ class ShapeString(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Shape from text" - _tip = ("Creates a shape from a text string by choosing " - "a specific font and a placement.\n" - "The closed shapes can be used for extrusions " - "and boolean operations.") + _menu = + _tip = () d = {'Pixmap': 'Draft_ShapeString', 'Accel': "S, S", - 'MenuText': QT_TRANSLATE_NOOP("Draft_ShapeString", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ShapeString", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_ShapeString", "Shape from text"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ShapeString", "Creates a shape from a text string by choosing a specific font and a placement.\nThe closed shapes can be used for extrusions and boolean operations.")} return d def Activated(self): diff --git a/src/Mod/Draft/draftguitools/gui_snaps.py b/src/Mod/Draft/draftguitools/gui_snaps.py index eccd8cafbf..362a2a1e9c 100644 --- a/src/Mod/Draft/draftguitools/gui_snaps.py +++ b/src/Mod/Draft/draftguitools/gui_snaps.py @@ -35,7 +35,7 @@ from PySide.QtCore import QT_TRANSLATE_NOOP import FreeCADGui as Gui import draftguitools.gui_base as gui_base -from draftutils.translate import _tr +from draftutils.translate import translate # UTILITIES ----------------------------------------------------------------- @@ -106,18 +106,15 @@ class Draft_Snap_Lock(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Lock, self).__init__(name=_tr("Main toggle snap")) + super(Draft_Snap_Lock, self).__init__(name=translate("draft","Main toggle snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Main snapping toggle On/Off" - _tip = ("Activates or deactivates " - "all snap methods at once.") return {'Pixmap': 'Snap_Lock', 'Accel': "Shift+S", - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Lock", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Lock", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Lock", "Main snapping toggle On/Off"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Lock", "Activates or deactivates all snap methods at once.")} def Activated(self): """Execute when the command is called.""" @@ -140,16 +137,14 @@ class Draft_Snap_Midpoint(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Midpoint, self).__init__(name=_tr("Midpoint snap")) + super(Draft_Snap_Midpoint, self).__init__(name=translate("draft","Midpoint snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Midpoint" - _tip = "Set snapping to the midpoint of an edge." return {'Pixmap': 'Snap_Midpoint', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", "Midpoint"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Midpoint", "Set snapping to the midpoint of an edge.")} def Activated(self): """Execute when the command is called.""" @@ -172,18 +167,14 @@ class Draft_Snap_Perpendicular(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Perpendicular, self).__init__(name=_tr("Perpendicular snap")) + super(Draft_Snap_Perpendicular, self).__init__(name=translate("draft","Perpendicular snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Perpendicular" - _tip = "Set snapping to a direction that is perpendicular to an edge." return {'Pixmap': 'Snap_Perpendicular', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Perpendicular", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Perpendicular", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Perpendicular", "Perpendicular"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Perpendicular", "Set snapping to a direction that is perpendicular to an edge.")} def Activated(self): """Execute when the command is called.""" @@ -206,15 +197,14 @@ class Draft_Snap_Grid(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Grid, self).__init__(name=_tr("Grid snap")) + super(Draft_Snap_Grid, self).__init__(name=translate("draft","Grid snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Set snapping to the intersection of grid lines." return {'Pixmap': 'Snap_Grid', 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Grid", "Grid"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Grid", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Grid", "Set snapping to the intersection of grid lines.")} def Activated(self): """Execute when the command is called.""" @@ -237,18 +227,14 @@ class Draft_Snap_Intersection(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Intersection, self).__init__(name=_tr("Intersection snap")) + super(Draft_Snap_Intersection, self).__init__(name=translate("draft","Intersection snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Intersection" - _tip = "Set snapping to the intersection of edges." return {'Pixmap': 'Snap_Intersection', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Intersection", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Intersection", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Intersection","Intersection"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Intersection","Set snapping to the intersection of edges.")} def Activated(self): """Execute when the command is called.""" @@ -271,16 +257,14 @@ class Draft_Snap_Parallel(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Parallel, self).__init__(name=_tr("Parallel snap")) + super(Draft_Snap_Parallel, self).__init__(name=translate("draft","Parallel snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Parallel" - _tip = "Set snapping to a direction that is parallel to an edge." return {'Pixmap': 'Snap_Parallel', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Parallel", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Parallel", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Parallel", "Parallel"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Parallel", "Set snapping to a direction that is parallel to an edge.")} def Activated(self): """Execute when the command is called.""" @@ -303,16 +287,14 @@ class Draft_Snap_Endpoint(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Endpoint, self).__init__(name=_tr("Endpoint snap")) + super(Draft_Snap_Endpoint, self).__init__(name=translate("draft","Endpoint snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Endpoint" - _tip = "Set snapping to endpoints of an edge." return {'Pixmap': 'Snap_Endpoint', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Endpoint", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Endpoint", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Endpoint", "Endpoint"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Endpoint", "Set snapping to endpoints of an edge.")} def Activated(self): """Execute when the command is called.""" @@ -336,17 +318,14 @@ class Draft_Snap_Angle(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Angle, self).__init__(name=_tr("Angle snap (30 and 45 degrees)")) + super(Draft_Snap_Angle, self).__init__(name=translate("draft","Angle snap (30 and 45 degrees)")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Angles (30 and 45 degrees)" - _tip = ("Set snapping to points in a circular arc located " - "at multiples of 30 and 45 degree angles.") return {'Pixmap': 'Snap_Angle', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Angle", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Angle", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Angle", "Angle"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Angle", "Set snapping to points in a circular arc located at multiples of 30 and 45 degree angles.")} def Activated(self): """Execute when the command is called.""" @@ -369,15 +348,14 @@ class Draft_Snap_Center(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Center, self).__init__(name=_tr("Arc center snap")) + super(Draft_Snap_Center, self).__init__(name=translate("draft","Arc center snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Set snapping to the center of a circular arc." return {'Pixmap': 'Snap_Center', 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Center", "Center"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Center", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Center", "Set snapping to the center of a circular arc.")} def Activated(self): """Execute when the command is called.""" @@ -400,16 +378,14 @@ class Draft_Snap_Extension(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Extension, self).__init__(name=_tr("Edge extension snap")) + super(Draft_Snap_Extension, self).__init__(name=translate("draft","Edge extension snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Extension" - _tip = "Set snapping to the extension of an edge." return {'Pixmap': 'Snap_Extension', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Extension", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Extension", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Extension", "Extension"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Extension", "Set snapping to the extension of an edge.")} def Activated(self): """Execute when the command is called.""" @@ -432,15 +408,14 @@ class Draft_Snap_Near(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Near, self).__init__(name=_tr("Near snap")) + super(Draft_Snap_Near, self).__init__(name=translate("draft","Near snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Set snapping to the nearest point of an edge." return {'Pixmap': 'Snap_Near', 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Near", "Nearest"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Near", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Near", "Set snapping to the nearest point of an edge.")} def Activated(self): """Execute when the command is called.""" @@ -464,17 +439,14 @@ class Draft_Snap_Ortho(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Ortho, self).__init__(name=_tr("Orthogonal snap")) + super(Draft_Snap_Ortho, self).__init__(name=translate("draft","Orthogonal snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Orthogonal angles (45 degrees)" - _tip = ("Set snapping to a direction that is a multiple " - "of 45 degrees from a point.") return {'Pixmap': 'Snap_Ortho', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Ortho", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Ortho", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Ortho", "Orthogonal"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Ortho", "Set snapping to a direction that is a multiple of 45 degrees from a point.")} def Activated(self): """Execute when the command is called.""" @@ -497,16 +469,14 @@ class Draft_Snap_Special(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Special, self).__init__(name=_tr("Special point snap")) + super(Draft_Snap_Special, self).__init__(name=translate("draft","Special point snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Special" - _tip = "Set snapping to the special points defined inside an object." return {'Pixmap': 'Snap_Special', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Special", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Special", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Special", "Special"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Special", "Set snapping to the special points defined inside an object.")} def Activated(self): """Execute when the command is called.""" @@ -530,17 +500,14 @@ class Draft_Snap_Dimensions(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_Dimensions, self).__init__(name=_tr("Dimension display")) + super(Draft_Snap_Dimensions, self).__init__(name=translate("draft","Dimension display")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Show dimensions" - _tip = ("Show temporary linear dimensions when editing an object " - "and using other snapping methods.") return {'Pixmap': 'Snap_Dimensions', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Dimensions", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Dimensions", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_Dimensions", "Show dimensions"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_Dimensions", "Show temporary linear dimensions when editing an object and using other snapping methods.")} def Activated(self): """Execute when the command is called.""" @@ -566,23 +533,14 @@ class Draft_Snap_WorkingPlane(gui_base.GuiCommandSimplest): """ def __init__(self): - super(Draft_Snap_WorkingPlane, self).__init__(name=_tr("Working plane snap")) + super(Draft_Snap_WorkingPlane, self).__init__(name=translate("draft","Working plane snap")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Working plane" - _tip = ("Restricts snapping to a point in the current " - "working plane.\n" - "If you select a point outside the working plane, " - "for example, by using other snapping methods,\n" - "it will snap to that point's projection " - "in the current working plane.") return {'Pixmap': 'Snap_WorkingPlane', - 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_WorkingPlane", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_WorkingPlane", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_Snap_WorkingPlane","Working plane"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Snap_WorkingPlane","Restricts snapping to a point in the current working plane.\nIf you select a point outside the working plane, for example, by using other snapping methods,\nit will snap to that point's projection in the current working plane.")} def Activated(self): """Execute when the command is called.""" @@ -605,17 +563,15 @@ class ShowSnapBar(gui_base.GuiCommandSimplest): """ def __init__(self): - super(ShowSnapBar, self).__init__(name=_tr("Show snap toolbar")) + super(ShowSnapBar, self).__init__(name=translate("draft","Show snap toolbar")) def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Show the snap toolbar if it is hidden." + _tip = return {'Pixmap': 'Draft_Snap', - 'MenuText': QT_TRANSLATE_NOOP("Draft_ShowSnapBar", - "Show snap toolbar"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ShowSnapBar", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_ShowSnapBar","Show snap toolbar"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ShowSnapBar","Show the snap toolbar if it is hidden.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_splines.py b/src/Mod/Draft/draftguitools/gui_splines.py index 925300e9d9..567ba54f20 100644 --- a/src/Mod/Draft/draftguitools/gui_splines.py +++ b/src/Mod/Draft/draftguitools/gui_splines.py @@ -54,13 +54,11 @@ class BSpline(gui_lines.Line): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Creates a multiple-point B-spline. " - "CTRL to snap, SHIFT to constrain.") return {'Pixmap': 'Draft_BSpline', 'Accel': "B, S", 'MenuText': QT_TRANSLATE_NOOP("Draft_BSpline", "B-spline"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_BSpline", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_BSpline", "Creates a multiple-point B-spline. CTRL to snap, SHIFT to constrain.")} def Activated(self): """Execute when the command is called. diff --git a/src/Mod/Draft/draftguitools/gui_split.py b/src/Mod/Draft/draftguitools/gui_split.py index 70f009335f..09e3f35f52 100644 --- a/src/Mod/Draft/draftguitools/gui_split.py +++ b/src/Mod/Draft/draftguitools/gui_split.py @@ -39,7 +39,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -50,21 +50,15 @@ class Split(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Splits the selected line or polyline " - "into two independent lines\n" - "or polylines by clicking anywhere " - "along the original object.\n" - "It works best when choosing a point on a straight segment " - "and not a corner vertex.") return {'Pixmap': 'Draft_Split', 'Accel': "S, P", 'MenuText': QT_TRANSLATE_NOOP("Draft_Split", "Split"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Split", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Split", "Splits the selected line or polyline into two independent lines\nor polylines by clicking anywhere along the original object.\nIt works best when choosing a point on a straight segment and not a corner vertex.")} def Activated(self): """Execute when the command is called.""" - super(Split, self).Activated(name=_tr("Split")) + super(Split, self).Activated(name=translate("draft","Split")) if not self.ui: return _msg(translate("draft", "Click anywhere on a line to split it.")) diff --git a/src/Mod/Draft/draftguitools/gui_stretch.py b/src/Mod/Draft/draftguitools/gui_stretch.py index 8f1e939f40..0139c067cf 100644 --- a/src/Mod/Draft/draftguitools/gui_stretch.py +++ b/src/Mod/Draft/draftguitools/gui_stretch.py @@ -47,7 +47,7 @@ import draftguitools.gui_tool_utils as gui_tool_utils import draftguitools.gui_trackers as trackers from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -58,20 +58,15 @@ class Stretch(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Stretches the selected objects.\n" - "Select an object, then draw a rectangle " - "to pick the vertices that will be stretched,\n" - "then draw a line to specify the distance " - "and direction of stretching.") return {'Pixmap': 'Draft_Stretch', 'Accel': "S, H", 'MenuText': QT_TRANSLATE_NOOP("Draft_Stretch", "Stretch"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Stretch", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Stretch", "Stretches the selected objects.\nSelect an object, then draw a rectangle to pick the vertices that will be stretched,\nthen draw a line to specify the distance and direction of stretching.")} def Activated(self): """Execute when the command is called.""" - super(Stretch, self).Activated(name=_tr("Stretch")) + super(Stretch, self).Activated(name=translate("draft","Stretch")) if self.ui: if not Gui.Selection.getSelection(): self.ui.selectUi() diff --git a/src/Mod/Draft/draftguitools/gui_styles.py b/src/Mod/Draft/draftguitools/gui_styles.py index d3431986d2..0c54884014 100644 --- a/src/Mod/Draft/draftguitools/gui_styles.py +++ b/src/Mod/Draft/draftguitools/gui_styles.py @@ -34,7 +34,7 @@ from PySide.QtCore import QT_TRANSLATE_NOOP import FreeCADGui as Gui import draftguitools.gui_base_original as gui_base_original -from draftutils.translate import translate, _tr +from draftutils.translate import translate class ApplyStyle(gui_base_original.Modifier): @@ -42,21 +42,17 @@ class ApplyStyle(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Apply current style" - _tip = ("Applies the current style defined in the toolbar " - "(line width and colors) " - "to the selected objects and groups.") return {'Pixmap': 'Draft_Apply', - 'MenuText': QT_TRANSLATE_NOOP("Draft_ApplyStyle", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ApplyStyle", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_ApplyStyle", "Apply current style"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ApplyStyle", "Applies the current style defined in the toolbar (line width and colors) to the selected objects and groups.")} def Activated(self): """Execute when the command is called. Activate the specific BSpline tracker. """ - super(ApplyStyle, self).Activated(name=_tr("Apply style")) + super(ApplyStyle, self).Activated(name=translate("draft","Apply style")) if self.ui: self.sel = Gui.Selection.getSelection() if len(self.sel) > 0: diff --git a/src/Mod/Draft/draftguitools/gui_subelements.py b/src/Mod/Draft/draftguitools/gui_subelements.py index 0455e6bb85..4abcc9770d 100644 --- a/src/Mod/Draft/draftguitools/gui_subelements.py +++ b/src/Mod/Draft/draftguitools/gui_subelements.py @@ -41,7 +41,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate class SubelementHighlight(gui_base_original.Modifier): @@ -54,25 +54,20 @@ class SubelementHighlight(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Subelement highlight" - _tip = ("Highlight the subelements " - "of the selected objects, " - "so that they can then be edited " - "with the move, rotate, and scale tools.") + _menu = + _tip = () return {'Pixmap': 'Draft_SubelementHighlight', 'Accel': "H, S", - 'MenuText': QT_TRANSLATE_NOOP("Draft_SubelementHighlight", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_SubelementHighlight", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_SubelementHighlight","Subelement highlight"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_SubelementHighlight","Highlight the subelements of the selected objects, so that they can then be edited with the move, rotate, and scale tools.")} def Activated(self): """Execute when the command is called.""" if self.is_running: return self.finish() self.is_running = True - super(SubelementHighlight, self).Activated(name=_tr("Subelement highlight")) + super(SubelementHighlight, self).Activated(name=translate("draft","Subelement highlight")) self.get_selection() def proceed(self): diff --git a/src/Mod/Draft/draftguitools/gui_texts.py b/src/Mod/Draft/draftguitools/gui_texts.py index 4cd0cacaf0..32523e04c8 100644 --- a/src/Mod/Draft/draftguitools/gui_texts.py +++ b/src/Mod/Draft/draftguitools/gui_texts.py @@ -54,12 +54,11 @@ class Text(gui_base_original.Creator): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = "Creates a multi-line annotation. CTRL to snap." return {'Pixmap': 'Draft_Text', 'Accel': "T, E", 'MenuText': QT_TRANSLATE_NOOP("Draft_Text", "Text"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Text", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Text", "Creates a multi-line annotation. CTRL to snap.")} def Activated(self): """Execute when the command is called.""" diff --git a/src/Mod/Draft/draftguitools/gui_togglemodes.py b/src/Mod/Draft/draftguitools/gui_togglemodes.py index 3f87ed1c1c..6798ed3550 100644 --- a/src/Mod/Draft/draftguitools/gui_togglemodes.py +++ b/src/Mod/Draft/draftguitools/gui_togglemodes.py @@ -40,7 +40,7 @@ import Draft_rc import draftguitools.gui_base as gui_base from draftutils.messages import _msg -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -70,7 +70,7 @@ class BaseMode(gui_base.GuiCommandSimplest): if hasattr(Gui, "draftToolBar"): _ui = Gui.draftToolBar else: - _msg(_tr("No active Draft Toolbar.")) + _msg(translate("draft","No active Draft Toolbar.")) return if _ui is not None: @@ -90,23 +90,15 @@ class ToggleConstructionMode(BaseMode): def __init__(self): super(ToggleConstructionMode, - self).__init__(name=_tr("Construction mode")) + self).__init__(name=translate("draft","Construction mode")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Toggle construction mode" - _tip = ("Toggles the Construction mode.\n" - "When this is active, the following objects created " - "will be included in the construction group, " - "and will be drawn with the specified color " - "and properties.") d = {'Pixmap': 'Draft_Construction', - 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleConstructionMode", - _menu), + 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleConstructionMode","Toggle construction mode"), 'Accel': "C, M", - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleConstructionMode", - _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleConstructionMode","Toggles the Construction mode.\nWhen this is active, the following objects created will be included in the construction group, and will be drawn with the specified color and properties.")} return d def Activated(self): @@ -130,22 +122,14 @@ class ToggleContinueMode(BaseMode): """ def __init__(self): - super(ToggleContinueMode, self).__init__(name=_tr("Continue mode")) + super(ToggleContinueMode, self).__init__(name=translate("draft","Continue mode")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Toggle continue mode" - _tip = ("Toggles the Continue mode.\n" - "When this is active, any drawing tool that is terminated " - "will automatically start again.\n" - "This can be used to draw several objects " - "one after the other in succession.") d = {'Pixmap': 'Draft_Continue', - 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleContinueMode", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleContinueMode", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleContinueMode","Toggle continue mode"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleContinueMode","Toggles the Continue mode.\nWhen this is active, any drawing tool that is terminated will automatically start again.\nThis can be used to draw several objects one after the other in succession.")} return d def Activated(self): @@ -172,24 +156,15 @@ class ToggleDisplayMode(gui_base.GuiCommandNeedsSelection): def __init__(self): super(ToggleDisplayMode, - self).__init__(name=_tr("Toggle display mode")) + self).__init__(name=translate("draft","Toggle display mode")) def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Toggle normal/wireframe display" - _tip = ("Switches the display mode of selected objects " - "from flatlines to wireframe and back.\n" - "This is helpful to quickly visualize objects " - "that are hidden by other objects.\n" - "This is intended to be used with closed shapes " - "and solids, and doesn't affect open wires.") d = {'Pixmap': 'Draft_SwitchMode', 'Accel': "Shift+Space", - 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleDisplayMode", - _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleDisplayMode", - _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_ToggleDisplayMode","Toggle normal/wireframe display"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_ToggleDisplayMode","Switches the display mode of selected objects from flatlines to wireframe and back.\nThis is helpful to quickly visualize objects that are hidden by other objects.\nThis is intended to be used with closed shapes and solids, and doesn't affect open wires.")} return d def Activated(self): diff --git a/src/Mod/Draft/draftguitools/gui_trimex.py b/src/Mod/Draft/draftguitools/gui_trimex.py index 3fbd04a1ef..88546b0716 100644 --- a/src/Mod/Draft/draftguitools/gui_trimex.py +++ b/src/Mod/Draft/draftguitools/gui_trimex.py @@ -52,7 +52,7 @@ import draftguitools.gui_tool_utils as gui_tool_utils import draftguitools.gui_trackers as trackers from draftutils.messages import _msg, _err -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -70,19 +70,15 @@ class Trimex(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Trims or extends the selected object, " - "or extrudes single faces.\n" - "CTRL snaps, SHIFT constrains to current segment " - "or to normal, ALT inverts.") return {'Pixmap': 'Draft_Trimex', 'Accel': "T, R", 'MenuText': QT_TRANSLATE_NOOP("Draft_Trimex", "Trimex"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Trimex", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Trimex", "Trims or extends the selected object, or extrudes single faces.\nCTRL snaps, SHIFT constrains to current segment or to normal, ALT inverts.")} def Activated(self): """Execute when the command is called.""" - super(Trimex, self).Activated(name=_tr("Trimex")) + super(Trimex, self).Activated(name=translate("draft","Trimex")) self.edges = [] self.placement = None self.ghost = [] diff --git a/src/Mod/Draft/draftguitools/gui_upgrade.py b/src/Mod/Draft/draftguitools/gui_upgrade.py index 088f02721c..fbab4fa431 100644 --- a/src/Mod/Draft/draftguitools/gui_upgrade.py +++ b/src/Mod/Draft/draftguitools/gui_upgrade.py @@ -41,7 +41,7 @@ import draftguitools.gui_base_original as gui_base_original import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -52,23 +52,15 @@ class Upgrade(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _tip = ("Upgrades the selected objects into more complex shapes.\n" - "The result of the operation depends on the types of objects, " - "which may be able to be upgraded several times in a row.\n" - "For example, it can join the selected objects into one, " - "convert simple edges into parametric polylines,\n" - "convert closed edges into filled faces " - "and parametric polygons, and merge faces " - "into a single face.") return {'Pixmap': 'Draft_Upgrade', 'Accel': "U, P", 'MenuText': QT_TRANSLATE_NOOP("Draft_Upgrade", "Upgrade"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_Upgrade", _tip)} + 'ToolTip': QT_TRANSLATE_NOOP("Draft_Upgrade", "Upgrades the selected objects into more complex shapes.\nThe result of the operation depends on the types of objects, which may be able to be upgraded several times in a row.\nFor example, it can join the selected objects into one, convert simple edges into parametric polylines,\nconvert closed edges into filled faces and parametric polygons, and merge faces into a single face.")} def Activated(self): """Execute when the command is called.""" - super(Upgrade, self).Activated(name=_tr("Upgrade")) + super(Upgrade, self).Activated(name=translate("draft","Upgrade")) if self.ui: if not Gui.Selection.getSelection(): self.ui.selectUi() diff --git a/src/Mod/Draft/draftguitools/gui_wire2spline.py b/src/Mod/Draft/draftguitools/gui_wire2spline.py index 37845ee79d..2c8c10e351 100644 --- a/src/Mod/Draft/draftguitools/gui_wire2spline.py +++ b/src/Mod/Draft/draftguitools/gui_wire2spline.py @@ -44,7 +44,7 @@ import Draft import draftutils.utils as utils import draftguitools.gui_base_original as gui_base_original -from draftutils.translate import translate, _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) True if Draft_rc.__name__ else False @@ -58,13 +58,10 @@ class WireToBSpline(gui_base_original.Modifier): def GetResources(self): """Set icon, menu and tooltip.""" - _menu = "Wire to B-spline" - _tip = ("Converts a selected polyline to a B-spline, " - "or a B-spline to a polyline.") return {'Pixmap': 'Draft_WireToBSpline', - 'MenuText': QT_TRANSLATE_NOOP("Draft_WireToBSpline", _menu), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_WireToBSpline", _tip)} + 'MenuText': QT_TRANSLATE_NOOP("Draft_WireToBSpline", "Wire to B-spline"), + 'ToolTip': QT_TRANSLATE_NOOP("Draft_WireToBSpline", "Converts a selected polyline to a B-spline, or a B-spline to a polyline.")} def Activated(self): """Execute when the command is called.""" @@ -79,7 +76,7 @@ class WireToBSpline(gui_base_original.Modifier): selection = Gui.Selection.getSelection() if selection: if utils.getType(selection[0]) in ['Wire', 'BSpline']: - super(WireToBSpline, self).Activated(name=_tr("Convert polyline/B-spline")) + super(WireToBSpline, self).Activated(name=translate("draft","Convert polyline/B-spline")) if self.doc: self.obj = Gui.Selection.getSelection() if self.obj: diff --git a/src/Mod/Draft/draftmake/make_arc_3points.py b/src/Mod/Draft/draftmake/make_arc_3points.py index c0a48abdf3..cb00898678 100644 --- a/src/Mod/Draft/draftmake/make_arc_3points.py +++ b/src/Mod/Draft/draftmake/make_arc_3points.py @@ -34,7 +34,7 @@ import Part import Draft import draftutils.utils as utils from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate import draftutils.gui_utils as gui_utils @@ -122,23 +122,21 @@ def make_arc_3points(points, placement=None, face=False, try: utils.type_check([(points, (list, tuple))], name=_name) except TypeError: - _err(_tr("Points: ") + "{}".format(points)) - _err(_tr("Wrong input: " - "must be list or tuple of three points exactly.")) + _err(translate("draft","Points: ") + "{}".format(points)) + _err(translate("draft","Wrong input: must be list or tuple of three points exactly.")) return None if len(points) != 3: - _err(_tr("Points: ") + "{}".format(points)) - _err(_tr("Wrong input: " - "must be list or tuple of three points exactly.")) + _err(translate("draft","Points: ") + "{}".format(points)) + _err(translate("draft","Wrong input: must be list or tuple of three points exactly.")) return None if placement is not None: try: utils.type_check([(placement, App.Placement)], name=_name) except TypeError: - _err(_tr("Placement: ") + "{}".format(placement)) - _err(_tr("Wrong input: incorrect type of placement.")) + _err(translate("draft","Placement: ") + "{}".format(placement)) + _err(translate("draft","Wrong input: incorrect type of placement.")) return None p1, p2, p3 = points @@ -152,24 +150,24 @@ def make_arc_3points(points, placement=None, face=False, (p2, App.Vector), (p3, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: incorrect type of points.")) + _err(translate("draft","Wrong input: incorrect type of points.")) return None try: _edge = Part.Arc(p1, p2, p3) except Part.OCCError as error: - _err(_tr("Cannot generate shape: ") + "{}".format(error)) + _err(translate("draft","Cannot generate shape: ") + "{}".format(error)) return None edge = _edge.toShape() radius = edge.Curve.Radius center = edge.Curve.Center - _msg(_tr("Radius: ") + "{}".format(radius)) - _msg(_tr("Center: ") + "{}".format(center)) + _msg(translate("draft","Radius:") + " " + "{}".format(radius)) + _msg(translate("draft","Center:") + " " + "{}".format(center)) if primitive: - _msg(_tr("Create primitive object")) + _msg(translate("draft","Create primitive object")) obj = App.ActiveDocument.addObject("Part::Feature", "Arc") obj.Shape = edge return obj @@ -192,18 +190,18 @@ def make_arc_3points(points, placement=None, face=False, if placement and not support: obj.Placement.Base = placement.Base - _msg(_tr("Final placement: ") + "{}".format(obj.Placement)) + _msg(translate("draft","Final placement:") + " " + "{}".format(obj.Placement)) if face: - _msg(_tr("Face: True")) + _msg(translate("draft","Face: True")) if support: - _msg(_tr("Support: ") + "{}".format(support)) - _msg(_tr("Map mode: " + "{}".format(map_mode))) + _msg(translate("draft","Support:") + " " + "{}".format(support)) + _msg(translate("draft","Map mode:") + " " + "{}".format(map_mode)) obj.MapMode = map_mode if placement: obj.AttachmentOffset.Base = placement.Base obj.AttachmentOffset.Rotation = original_placement.Rotation - _msg(_tr("Attachment offset: {}".format(obj.AttachmentOffset))) - _msg(_tr("Final placement: ") + "{}".format(obj.Placement)) + _msg(translate("draft","Attachment offset: {}".format(obj.AttachmentOffset))) + _msg(translate("draft","Final placement:") + " " + "{}".format(obj.Placement)) return obj diff --git a/src/Mod/Draft/draftmake/make_array.py b/src/Mod/Draft/draftmake/make_array.py index ab9982ff28..0109b6c322 100644 --- a/src/Mod/Draft/draftmake/make_array.py +++ b/src/Mod/Draft/draftmake/make_array.py @@ -35,7 +35,7 @@ import draftutils.utils as utils import draftutils.gui_utils as gui_utils from draftutils.messages import _wrn, _err -from draftutils.translate import _tr +from draftutils.translate import translate from draftobjects.array import Array if App.GuiUp: @@ -82,7 +82,7 @@ def make_array(base_object, """ found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if use_link: diff --git a/src/Mod/Draft/draftmake/make_circulararray.py b/src/Mod/Draft/draftmake/make_circulararray.py index f1611ecccd..9b7bde9e0c 100644 --- a/src/Mod/Draft/draftmake/make_circulararray.py +++ b/src/Mod/Draft/draftmake/make_circulararray.py @@ -32,7 +32,7 @@ import draftmake.make_array as make_array import draftutils.utils as utils from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate def make_circular_array(base_object, @@ -119,7 +119,7 @@ def make_circular_array(base_object, make_ortho_array, make_polar_array, make_path_array, make_point_array """ _name = "make_circular_array" - utils.print_header(_name, _tr("Circular array")) + utils.print_header(_name, translate("draft","Circular array")) if isinstance(base_object, str): base_object_str = base_object @@ -128,7 +128,7 @@ def make_circular_array(base_object, doc=App.activeDocument()) if not found: _msg("base_object: {}".format(base_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("base_object: {}".format(base_object.Label)) @@ -141,7 +141,7 @@ def make_circular_array(base_object, (tan_distance, (int, float, App.Units.Quantity))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a number or quantity.")) + _err(translate("draft","Wrong input: must be a number or quantity.")) return None _msg("number: {}".format(number)) @@ -151,7 +151,7 @@ def make_circular_array(base_object, utils.type_check([(number, int), (symmetry, int)], name=_name) except TypeError: - _err(_tr("Wrong input: must be an integer number.")) + _err(translate("draft","Wrong input: must be an integer number.")) return None _msg("axis: {}".format(axis)) @@ -161,7 +161,7 @@ def make_circular_array(base_object, utils.type_check([(axis, App.Vector), (center, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None use_link = bool(use_link) diff --git a/src/Mod/Draft/draftmake/make_dimension.py b/src/Mod/Draft/draftmake/make_dimension.py index 2f82422ef6..9cd4ebfe8d 100644 --- a/src/Mod/Draft/draftmake/make_dimension.py +++ b/src/Mod/Draft/draftmake/make_dimension.py @@ -40,7 +40,7 @@ import draftutils.utils as utils import draftutils.gui_utils as gui_utils from draftutils.messages import _msg, _wrn, _err -from draftutils.translate import _tr +from draftutils.translate import translate from draftobjects.dimension import (LinearDimension, AngularDimension) @@ -170,10 +170,8 @@ def make_dimension(p1, p2, p3=None, p4=None): def makeDimension(p1, p2, p3=None, p4=None): """Create a dimension. DEPRECATED. Use 'make_dimension'.""" - _wrn(_tr("This function is deprecated. " - "Do not use this function directly.")) - _wrn(_tr("Use one of 'make_linear_dimension', or " - "'make_linear_dimension_obj'.")) + _wrn(translate("draft","This function is deprecated. Do not use this function directly.")) + _wrn(translate("draft","Use one of 'make_linear_dimension', or 'make_linear_dimension_obj'.")) return make_dimension(p1, p2, p3, p4) @@ -214,21 +212,21 @@ def make_linear_dimension(p1, p2, dim_line=None): found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None _msg("p1: {}".format(p1)) try: utils.type_check([(p1, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None _msg("p2: {}".format(p2)) try: utils.type_check([(p2, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None _msg("dim_line: {}".format(dim_line)) @@ -236,7 +234,7 @@ def make_linear_dimension(p1, p2, dim_line=None): try: utils.type_check([(dim_line, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None else: diff = p2.sub(p1) @@ -307,7 +305,7 @@ def make_linear_dimension_obj(edge_object, i1=1, i2=2, dim_line=None): found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if isinstance(edge_object, str): @@ -315,56 +313,54 @@ def make_linear_dimension_obj(edge_object, i1=1, i2=2, dim_line=None): if isinstance(edge_object, (list, tuple)): _msg("edge_object: {}".format(edge_object)) - _err(_tr("Wrong input: object must not be a list.")) + _err(translate("draft","Wrong input: object must not be a list.")) return None found, edge_object = utils.find_object(edge_object, doc) if not found: _msg("edge_object: {}".format(edge_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("edge_object: {}".format(edge_object.Label)) if not hasattr(edge_object, "Shape"): - _err(_tr("Wrong input: object doesn't have a 'Shape' to measure.")) + _err(translate("draft","Wrong input: object doesn't have a 'Shape' to measure.")) return None if (not hasattr(edge_object.Shape, "Vertexes") or len(edge_object.Shape.Vertexes) < 1): - _err(_tr("Wrong input: object doesn't have at least one element " - "in 'Vertexes' to use for measuring.")) + _err(translate("draft","Wrong input: object doesn't have at least one element in 'Vertexes' to use for measuring.")) return None _msg("i1: {}".format(i1)) try: utils.type_check([(i1, int)], name=_name) except TypeError: - _err(_tr("Wrong input: must be an integer.")) + _err(translate("draft","Wrong input: must be an integer.")) return None if i1 < 1: i1 = 1 - _wrn(_tr("i1: values below 1 are not allowed; will be set to 1.")) + _wrn(translate("draft","i1: values below 1 are not allowed; will be set to 1.")) vx1 = edge_object.getSubObject("Vertex" + str(i1)) if not vx1: - _err(_tr("Wrong input: vertex not in object.")) + _err(translate("draft","Wrong input: vertex not in object.")) return None _msg("i2: {}".format(i2)) try: utils.type_check([(i2, int)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None if i2 < 1: i2 = len(edge_object.Shape.Vertexes) - _wrn(_tr("i2: values below 1 are not allowed; " - "will be set to the last vertex in the object.")) + _wrn(translate("draft","i2: values below 1 are not allowed; will be set to the last vertex in the object.")) vx2 = edge_object.getSubObject("Vertex" + str(i2)) if not vx2: - _err(_tr("Wrong input: vertex not in object.")) + _err(translate("draft","Wrong input: vertex not in object.")) return None _msg("dim_line: {}".format(dim_line)) @@ -372,7 +368,7 @@ def make_linear_dimension_obj(edge_object, i1=1, i2=2, dim_line=None): try: utils.type_check([(dim_line, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None else: diff = vx2.Point.sub(vx1.Point) @@ -439,7 +435,7 @@ def make_radial_dimension_obj(edge_object, index=1, mode="radius", found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if isinstance(edge_object, str): @@ -448,49 +444,47 @@ def make_radial_dimension_obj(edge_object, index=1, mode="radius", found, edge_object = utils.find_object(edge_object, doc) if not found: _msg("edge_object: {}".format(edge_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("edge_object: {}".format(edge_object.Label)) if not hasattr(edge_object, "Shape"): - _err(_tr("Wrong input: object doesn't have a 'Shape' to measure.")) + _err(translate("draft","Wrong input: object doesn't have a 'Shape' to measure.")) return None if (not hasattr(edge_object.Shape, "Edges") or len(edge_object.Shape.Edges) < 1): - _err(_tr("Wrong input: object doesn't have at least one element " - "in 'Edges' to use for measuring.")) + _err(translate("draft","Wrong input: object doesn't have at least one element in 'Edges' to use for measuring.")) return None _msg("index: {}".format(index)) try: utils.type_check([(index, int)], name=_name) except TypeError: - _err(_tr("Wrong input: must be an integer.")) + _err(translate("draft","Wrong input: must be an integer.")) return None if index < 1: index = 1 - _wrn(_tr("index: values below 1 are not allowed; will be set to 1.")) + _wrn(translate("draft","index: values below 1 are not allowed; will be set to 1.")) edge = edge_object.getSubObject("Edge" + str(index)) if not edge: - _err(_tr("Wrong input: index doesn't correspond to an edge " - "in the object.")) + _err(translate("draft","Wrong input: index doesn't correspond to an edge in the object.")) return None if not hasattr(edge, "Curve") or edge.Curve.TypeId != 'Part::GeomCircle': - _err(_tr("Wrong input: index doesn't correspond to a circular edge.")) + _err(translate("draft","Wrong input: index doesn't correspond to a circular edge.")) return None _msg("mode: {}".format(mode)) try: utils.type_check([(mode, str)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a string, 'radius' or 'diameter'.")) + _err(translate("draft","Wrong input: must be a string, 'radius' or 'diameter'.")) return None if mode not in ("radius", "diameter"): - _err(_tr("Wrong input: must be a string, 'radius' or 'diameter'.")) + _err(translate("draft","Wrong input: must be a string, 'radius' or 'diameter'.")) return None _msg("dim_line: {}".format(dim_line)) @@ -498,7 +492,7 @@ def make_radial_dimension_obj(edge_object, index=1, mode="radius", try: utils.type_check([(dim_line, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None else: center = edge_object.Shape.Edges[index - 1].Curve.Center @@ -563,14 +557,14 @@ def make_angular_dimension(center=App.Vector(0, 0, 0), found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None _msg("center: {}".format(center)) try: utils.type_check([(center, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None _msg("angles: {}".format(angles)) @@ -578,14 +572,14 @@ def make_angular_dimension(center=App.Vector(0, 0, 0), utils.type_check([(angles, (tuple, list))], name=_name) if len(angles) != 2: - _err(_tr("Wrong input: must be a list with two angles.")) + _err(translate("draft","Wrong input: must be a list with two angles.")) return None ang1, ang2 = angles utils.type_check([(ang1, (int, float)), (ang2, (int, float))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a list with two angles.")) + _err(translate("draft","Wrong input: must be a list with two angles.")) return None # If the angle is larger than 360 degrees, make sure @@ -598,7 +592,7 @@ def make_angular_dimension(center=App.Vector(0, 0, 0), try: utils.type_check([(dim_line, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None _msg("normal: {}".format(normal)) @@ -606,7 +600,7 @@ def make_angular_dimension(center=App.Vector(0, 0, 0), try: utils.type_check([(dim_line, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None if not normal: diff --git a/src/Mod/Draft/draftmake/make_fillet.py b/src/Mod/Draft/draftmake/make_fillet.py index 25b68aa4c5..4d95055488 100644 --- a/src/Mod/Draft/draftmake/make_fillet.py +++ b/src/Mod/Draft/draftmake/make_fillet.py @@ -35,7 +35,7 @@ import draftutils.gui_utils as gui_utils import draftobjects.fillet as fillet from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate if App.GuiUp: import draftviewproviders.view_fillet as view_fillet @@ -55,7 +55,7 @@ def _print_obj_length(obj, edge, num=1): name = num _msg("({0}): {1}; {2} {3}".format(num, name, - _tr("length:"), edge.Length)) + translate("draft","length:"), edge.Length)) def _extract_edges(objs): @@ -129,20 +129,20 @@ def make_fillet(objs, radius=100, chamfer=False, delete=False): utils.print_header(_name, "Fillet") if len(objs) != 2: - _err(_tr("Two elements are needed.")) + _err(translate("draft","Two elements are needed.")) return None e1, e2 = _extract_edges(objs) edges = DraftGeomUtils.fillet([e1, e2], radius, chamfer) if len(edges) < 3: - _err(_tr("Radius is too large") + ", r={}".format(radius)) + _err(translate("draft","Radius is too large") + ", r={}".format(radius)) return None lengths = [edges[0].Length, edges[1].Length, edges[2].Length] - _msg(_tr("Segment") + " 1, " + _tr("length:") + " {}".format(lengths[0])) - _msg(_tr("Segment") + " 2, " + _tr("length:") + " {}".format(lengths[1])) - _msg(_tr("Segment") + " 3, " + _tr("length:") + " {}".format(lengths[2])) + _msg(translate("draft","Segment") + " 1, " + translate("draft","length:") + " {}".format(lengths[0])) + _msg(translate("draft","Segment") + " 2, " + translate("draft","length:") + " {}".format(lengths[1])) + _msg(translate("draft","Segment") + " 3, " + translate("draft","length:") + " {}".format(lengths[2])) try: wire = Part.Wire(edges) @@ -162,7 +162,7 @@ def make_fillet(objs, radius=100, chamfer=False, delete=False): if delete: _doc.removeObject(objs[0].Name) _doc.removeObject(objs[1].Name) - _msg(_tr("Removed original objects.")) + _msg(translate("draft","Removed original objects.")) if App.GuiUp: view_fillet.ViewProviderFillet(obj.ViewObject) diff --git a/src/Mod/Draft/draftmake/make_label.py b/src/Mod/Draft/draftmake/make_label.py index aee4450d61..6a92c203e9 100644 --- a/src/Mod/Draft/draftmake/make_label.py +++ b/src/Mod/Draft/draftmake/make_label.py @@ -35,7 +35,7 @@ import draftutils.gui_utils as gui_utils import draftutils.utils as utils from draftutils.messages import _msg, _wrn, _err -from draftutils.translate import _tr +from draftutils.translate import translate from draftobjects.label import Label if App.GuiUp: @@ -191,7 +191,7 @@ def make_label(target_point=App.Vector(0, 0, 0), found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None _msg("target_point: {}".format(target_point)) @@ -200,7 +200,7 @@ def make_label(target_point=App.Vector(0, 0, 0), try: utils.type_check([(target_point, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None _msg("placement: {}".format(placement)) @@ -211,8 +211,7 @@ def make_label(target_point=App.Vector(0, 0, 0), App.Vector, App.Rotation))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a placement, a vector, " - "or a rotation.")) + _err(translate("draft","Wrong input: must be a placement, a vector, or a rotation.")) return None # Convert the vector or rotation to a full placement @@ -227,13 +226,13 @@ def make_label(target_point=App.Vector(0, 0, 0), if target_object: if isinstance(target_object, (list, tuple)): _msg("target_object: {}".format(target_object)) - _err(_tr("Wrong input: object must not be a list.")) + _err(translate("draft","Wrong input: object must not be a list.")) return None found, target_object = utils.find_object(target_object, doc) if not found: _msg("target_object: {}".format(target_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("target_object: {}".format(target_object.Label)) @@ -248,8 +247,7 @@ def make_label(target_point=App.Vector(0, 0, 0), utils.type_check([(subelements, (list, tuple, str))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a list or tuple of strings. " - "Or a single string.")) + _err(translate("draft","Wrong input: must be a list or tuple of strings, or a single string.")) return None # The subelements list is used to build a special list @@ -261,7 +259,7 @@ def make_label(target_point=App.Vector(0, 0, 0), _sub = target_object.getSubObject(sub) if not _sub: _err("subelement: {}".format(sub)) - _err(_tr("Wrong input: subelement not in object.")) + _err(translate("draft","Wrong input: subelement not in object.")) return None _msg("label_type: {}".format(label_type)) @@ -270,16 +268,12 @@ def make_label(target_point=App.Vector(0, 0, 0), try: utils.type_check([(label_type, str)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a string, " - "'Custom', 'Name', 'Label', 'Position', " - "'Length', 'Area', 'Volume', 'Tag', or 'Material'.")) + _err(translate("draft","Wrong input: must be a string, 'Custom', 'Name', 'Label', 'Position', 'Length', 'Area', 'Volume', 'Tag', or 'Material'.")) return None if label_type not in ("Custom", "Name", "Label", "Position", "Length", "Area", "Volume", "Tag", "Material"): - _err(_tr("Wrong input: must be a string, " - "'Custom', 'Name', 'Label', 'Position', " - "'Length', 'Area', 'Volume', 'Tag', or 'Material'.")) + _err(translate("draft","Wrong input: must be a string, 'Custom', 'Name', 'Label', 'Position', 'Length', 'Area', 'Volume', 'Tag', or 'Material'.")) return None _msg("custom_text: {}".format(custom_text)) @@ -288,7 +282,7 @@ def make_label(target_point=App.Vector(0, 0, 0), try: utils.type_check([(custom_text, str)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a string.")) + _err(translate("draft","Wrong input: must be a string.")) return None _msg("direction: {}".format(direction)) @@ -297,13 +291,11 @@ def make_label(target_point=App.Vector(0, 0, 0), try: utils.type_check([(direction, str)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a string, " - "'Horizontal', 'Vertical', or 'Custom'.")) + _err(translate("draft","Wrong input: must be a string, 'Horizontal', 'Vertical', or 'Custom'.")) return None if direction not in ("Horizontal", "Vertical", "Custom"): - _err(_tr("Wrong input: must be a string, " - "'Horizontal', 'Vertical', or 'Custom'.")) + _err(translate("draft","Wrong input: must be a string, 'Horizontal', 'Vertical', or 'Custom'.")) return None _msg("distance: {}".format(distance)) @@ -312,13 +304,13 @@ def make_label(target_point=App.Vector(0, 0, 0), try: utils.type_check([(distance, (int, float))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a number.")) + _err(translate("draft","Wrong input: must be a number.")) return None if points: _msg("points: {}".format(points)) - _err_msg = _tr("Wrong input: must be a list of at least two vectors.") + _err_msg = translate("draft","Wrong input: must be a list of at least two vectors.") try: utils.type_check([(points, (tuple, list))], name=_name) except TypeError: @@ -352,8 +344,7 @@ def make_label(target_point=App.Vector(0, 0, 0), new_obj.StraightDistance = distance if points: if direction != "Custom": - _wrn(_tr("Direction is not 'Custom'; " - "points won't be used.")) + _wrn(translate("draft","Direction is not 'Custom'; points won't be used.")) new_obj.Points = points if App.GuiUp: @@ -380,8 +371,7 @@ def makeLabel(targetpoint=None, target=None, direction=None, utils.type_check([(target, (tuple, list))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a list of two elements. " - "For example, [object, 'Edge1'].")) + _err(translate("draft","Wrong input: must be a list of two elements. For example, [object, 'Edge1'].")) return None # In the old function `target` is the original parameter, diff --git a/src/Mod/Draft/draftmake/make_layer.py b/src/Mod/Draft/draftmake/make_layer.py index 9c4ad734df..4a315bc5fc 100644 --- a/src/Mod/Draft/draftmake/make_layer.py +++ b/src/Mod/Draft/draftmake/make_layer.py @@ -32,7 +32,7 @@ import FreeCAD as App import draftutils.utils as utils from draftutils.messages import _msg, _err -from draftutils.translate import _tr, translate +from draftutils.translate import translate from draftobjects.layer import (Layer, LayerContainer) @@ -55,7 +55,7 @@ def get_layer_container(): """ found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None for obj in doc.Objects: @@ -142,11 +142,11 @@ def make_layer(name=None, If there is a problem it will return `None`. """ _name = "make_layer" - utils.print_header(_name, _tr("Layer")) + utils.print_header(_name, translate("draft","Layer")) found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if name: @@ -154,23 +154,21 @@ def make_layer(name=None, try: utils.type_check([(name, str)], name=_name) except TypeError: - _err(_tr("Wrong input: it must be a string.")) + _err(translate("draft","Wrong input: it must be a string.")) return None else: name = translate("draft", "Layer") - _info_color = ("Wrong input: " - "must be a tuple of three floats 0.0 to 1.0.") if line_color: _msg("line_color: {}".format(line_color)) try: utils.type_check([(line_color, tuple)], name=_name) except TypeError: - _err(_tr(_info_color)) + _err(translate("draft","Wrong input: must be a tuple of three floats 0.0 to 1.0.")) return None if not all(isinstance(color, (int, float)) for color in line_color): - _err(_tr(_info_color)) + _err(translate("draft","Wrong input: must be a tuple of three floats 0.0 to 1.0.")) return None else: c = view_group.GetUnsigned("DefaultShapeLineColor", 255) @@ -183,11 +181,11 @@ def make_layer(name=None, try: utils.type_check([(shape_color, tuple)], name=_name) except TypeError: - _err(_tr(_info_color)) + _err(translate("draft","Wrong input: must be a tuple of three floats 0.0 to 1.0.")) return None if not all(isinstance(color, (int, float)) for color in shape_color): - _err(_tr(_info_color)) + _err(translate("draft","Wrong input: must be a tuple of three floats 0.0 to 1.0.")) return None else: c = view_group.GetUnsigned("DefaultShapeColor", 4294967295) @@ -200,20 +198,18 @@ def make_layer(name=None, utils.type_check([(line_width, (int, float))], name=_name) line_width = float(abs(line_width)) except TypeError: - _err(_tr("Wrong input: must be a number.")) + _err(translate("draft","Wrong input: must be a number.")) return None - _info_style = ("Wrong input: " - "must be 'Solid', 'Dashed', 'Dotted', or 'Dashdot'.") _msg("draw_style: {}".format(draw_style)) try: utils.type_check([(draw_style, str)], name=_name) except TypeError: - _err(_tr(_info_style)) + _err(translate("draft","Wrong input: must be 'Solid', 'Dashed', 'Dotted', or 'Dashdot'.")) return None if draw_style not in ('Solid', 'Dashed', 'Dotted', 'Dashdot'): - _err(_tr(_info_style)) + _err(translate("draft","Wrong input: must be 'Solid', 'Dashed', 'Dotted', or 'Dashdot'.")) return None _msg("transparency: {}".format(transparency)) @@ -221,7 +217,7 @@ def make_layer(name=None, utils.type_check([(transparency, (int, float))], name=_name) transparency = int(abs(transparency)) except TypeError: - _err(_tr("Wrong input: must be a number between 0 and 100.")) + _err(translate("draft","Wrong input: must be a number between 0 and 100.")) return None new_obj = doc.addObject("App::FeaturePython", "Layer") diff --git a/src/Mod/Draft/draftmake/make_orthoarray.py b/src/Mod/Draft/draftmake/make_orthoarray.py index af2299b43a..36ed7b8a59 100644 --- a/src/Mod/Draft/draftmake/make_orthoarray.py +++ b/src/Mod/Draft/draftmake/make_orthoarray.py @@ -32,7 +32,7 @@ import draftutils.utils as utils import draftmake.make_array as make_array from draftutils.messages import _msg, _wrn, _err -from draftutils.translate import _tr +from draftutils.translate import translate def _make_ortho_array(base_object, @@ -57,7 +57,7 @@ def _make_ortho_array(base_object, This should be handled by the subfunctions that use this one. """ _name = "_make_ortho_array" - utils.print_header(_name, _tr("Internal orthogonal array"), debug=False) + utils.print_header(_name, translate("draft","Internal orthogonal array"), debug=False) new_obj = make_array.make_array(base_object, arg1=v_x, arg2=v_y, arg3=v_z, @@ -84,19 +84,18 @@ def _are_vectors(v_x, v_y, v_z=None, name="Unknown"): (v_y, (int, float, App.Vector))], name=name) except TypeError: - _err(_tr("Wrong input: must be a number or vector.")) + _err(translate("draft","Wrong input: must be a number or vector.")) return False, v_x, v_y, v_z - _text = "Input: single value expanded to vector." if not isinstance(v_x, App.Vector): v_x = App.Vector(v_x, 0, 0) - _wrn(_tr(_text)) + _wrn(translate("draft","Input: single value expanded to vector.")) if not isinstance(v_y, App.Vector): v_y = App.Vector(0, v_y, 0) - _wrn(_tr(_text)) + _wrn(translate("draft","Input: single value expanded to vector.")) if v_z and not isinstance(v_z, App.Vector): v_z = App.Vector(0, 0, v_z) - _wrn(_tr(_text)) + _wrn(translate("draft","Input: single value expanded to vector.")) return True, v_x, v_y, v_z @@ -117,19 +116,17 @@ def _are_integers(n_x, n_y, n_z=None, name="Unknown"): utils.type_check([(n_x, int), (n_y, int)], name=name) except TypeError: - _err(_tr("Wrong input: must be an integer number.")) + _err(translate("draft","Wrong input: must be an integer number.")) return False, n_x, n_y, n_z - _text = ("Input: number of elements must be at least 1. " - "It is set to 1.") if n_x < 1: - _wrn(_tr(_text)) + _wrn(translate("draft","Input: number of elements must be at least 1. It is set to 1.")) n_x = 1 if n_y < 1: - _wrn(_tr(_text)) + _wrn(translate("draft","Input: number of elements must be at least 1. It is set to 1.")) n_y = 1 if n_z and n_z < 1: - _wrn(_tr(_text)) + _wrn(translate("draft","Input: number of elements must be at least 1. It is set to 1.")) n_z = 1 return True, n_x, n_y, n_z @@ -151,7 +148,7 @@ def _are_numbers(d_x, d_y, d_z=None, name="Unknown"): utils.type_check([(d_x, (int, float)), (d_y, (int, float))], name=name) except TypeError: - _err(_tr("Wrong input: must be a number.")) + _err(translate("draft","Wrong input: must be a number.")) return False, d_x, d_y, d_z return True, d_x, d_y, d_z @@ -167,7 +164,7 @@ def _find_object_in_doc(base_object, doc=None): doc=doc) if not found: _msg("base_object: {}".format(base_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return not FOUND, base_object _msg("base_object: {}".format(base_object.Label)) @@ -275,7 +272,7 @@ def make_ortho_array(base_object, make_circular_array, make_path_array, make_point_array """ _name = "make_ortho_array" - utils.print_header(_name, _tr("Orthogonal array")) + utils.print_header(_name, translate("draft","Orthogonal array")) found, base_object = _find_object_in_doc(base_object, doc=App.activeDocument()) @@ -350,7 +347,7 @@ def make_ortho_array2d(base_object, make_circular_array, make_path_array, make_point_array """ _name = "make_ortho_array2d" - utils.print_header(_name, _tr("Orthogonal array 2D")) + utils.print_header(_name, translate("draft","Orthogonal array 2D")) found, base_object = _find_object_in_doc(base_object, doc=App.activeDocument()) @@ -424,7 +421,7 @@ def make_rect_array(base_object, make_circular_array, make_path_array, make_point_array """ _name = "make_rect_array" - utils.print_header(_name, _tr("Rectangular array")) + utils.print_header(_name, translate("draft","Rectangular array")) found, base_object = _find_object_in_doc(base_object, doc=App.activeDocument()) @@ -501,7 +498,7 @@ def make_rect_array2d(base_object, make_circular_array, make_path_array, make_point_array """ _name = "make_rect_array2d" - utils.print_header(_name, _tr("Rectangular array 2D")) + utils.print_header(_name, translate("draft","Rectangular array 2D")) found, base_object = _find_object_in_doc(base_object, doc=App.activeDocument()) diff --git a/src/Mod/Draft/draftmake/make_patharray.py b/src/Mod/Draft/draftmake/make_patharray.py index bd23218a8f..f5848adb73 100644 --- a/src/Mod/Draft/draftmake/make_patharray.py +++ b/src/Mod/Draft/draftmake/make_patharray.py @@ -41,7 +41,7 @@ import draftutils.utils as utils import draftutils.gui_utils as gui_utils from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate from draftobjects.patharray import PathArray from draftobjects.pathtwistedarray import PathTwistedArray @@ -158,7 +158,7 @@ def make_path_array(base_object, path_object, count=4, found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if isinstance(base_object, str): @@ -167,7 +167,7 @@ def make_path_array(base_object, path_object, count=4, found, base_object = utils.find_object(base_object, doc) if not found: _msg("base_object: {}".format(base_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("base_object: {}".format(base_object.Label)) @@ -178,7 +178,7 @@ def make_path_array(base_object, path_object, count=4, found, path_object = utils.find_object(path_object, doc) if not found: _msg("path_object: {}".format(path_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("path_object: {}".format(path_object.Label)) @@ -188,7 +188,7 @@ def make_path_array(base_object, path_object, count=4, utils.type_check([(count, (int, float))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a number.")) + _err(translate("draft","Wrong input: must be a number.")) return None count = int(count) @@ -197,7 +197,7 @@ def make_path_array(base_object, path_object, count=4, utils.type_check([(extra, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None _msg("subelements: {}".format(subelements)) @@ -210,8 +210,7 @@ def make_path_array(base_object, path_object, count=4, utils.type_check([(subelements, (list, tuple, str))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a list or tuple of strings. " - "Or a single string.")) + _err(translate("draft","Wrong input: must be a list or tuple of strings, or a single string.")) return None # The subelements list is used to build a special list @@ -244,8 +243,7 @@ def make_path_array(base_object, path_object, count=4, if align_mode not in ("Original", "Frenet", "Tangent"): raise TypeError except TypeError: - _err(_tr("Wrong input: must be " - "'Original', 'Frenet', or 'Tangent'.")) + _err(translate("draft","Wrong input: must be 'Original', 'Frenet', or 'Tangent'.")) return None _msg("tan_vector: {}".format(tan_vector)) @@ -253,7 +251,7 @@ def make_path_array(base_object, path_object, count=4, utils.type_check([(tan_vector, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None force_vertical = bool(force_vertical) @@ -264,7 +262,7 @@ def make_path_array(base_object, path_object, count=4, utils.type_check([(vertical_vector, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None use_link = bool(use_link) @@ -329,7 +327,7 @@ def make_path_twisted_array(base_object, path_object, found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if isinstance(base_object, str): @@ -338,7 +336,7 @@ def make_path_twisted_array(base_object, path_object, found, base_object = utils.find_object(base_object, doc) if not found: _msg("base_object: {}".format(base_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("base_object: {}".format(base_object.Label)) @@ -349,7 +347,7 @@ def make_path_twisted_array(base_object, path_object, found, path_object = utils.find_object(path_object, doc) if not found: _msg("path_object: {}".format(path_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("path_object: {}".format(path_object.Label)) @@ -359,7 +357,7 @@ def make_path_twisted_array(base_object, path_object, utils.type_check([(count, (int, float))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a number.")) + _err(translate("draft","Wrong input: must be a number.")) return None count = int(count) diff --git a/src/Mod/Draft/draftmake/make_pointarray.py b/src/Mod/Draft/draftmake/make_pointarray.py index 1935d26cec..2e817fc341 100644 --- a/src/Mod/Draft/draftmake/make_pointarray.py +++ b/src/Mod/Draft/draftmake/make_pointarray.py @@ -40,7 +40,7 @@ import draftutils.utils as utils import draftutils.gui_utils as gui_utils from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate from draftobjects.pointarray import PointArray if App.GuiUp: @@ -105,7 +105,7 @@ def make_point_array(base_object, point_object, extra=None, use_link=True): found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if isinstance(base_object, str): @@ -114,7 +114,7 @@ def make_point_array(base_object, point_object, extra=None, use_link=True): found, base_object = utils.find_object(base_object, doc) if not found: _msg("base_object: {}".format(base_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("base_object: {}".format(base_object.Label)) @@ -125,15 +125,14 @@ def make_point_array(base_object, point_object, extra=None, use_link=True): found, point_object = utils.find_object(point_object, doc) if not found: _msg("point_object: {}".format(point_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("point_object: {}".format(point_object.Label)) if (not hasattr(point_object, "Geometry") and not hasattr(point_object, "Links") and not hasattr(point_object, "Components")): - _err(_tr("Wrong input: point object doesn't have " - "'Geometry', 'Links', or 'Components'.")) + _err(translate("draft","Wrong input: point object doesn't have 'Geometry', 'Links', or 'Components'.")) return None _msg("extra: {}".format(extra)) @@ -145,8 +144,7 @@ def make_point_array(base_object, point_object, extra=None, use_link=True): App.Rotation))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a placement, a vector, " - "or a rotation.")) + _err(translate("draft","Wrong input: must be a placement, a vector, or a rotation.")) return None # Convert the vector or rotation to a full placement diff --git a/src/Mod/Draft/draftmake/make_polararray.py b/src/Mod/Draft/draftmake/make_polararray.py index c0ba77bc31..a4341e6eb6 100644 --- a/src/Mod/Draft/draftmake/make_polararray.py +++ b/src/Mod/Draft/draftmake/make_polararray.py @@ -32,7 +32,7 @@ import draftutils.utils as utils import draftmake.make_array as make_array from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate def make_polar_array(base_object, @@ -91,7 +91,7 @@ def make_polar_array(base_object, make_ortho_array, make_circular_array, make_path_array, make_point_array """ _name = "make_polar_array" - utils.print_header(_name, _tr("Polar array")) + utils.print_header(_name, translate("draft","Polar array")) if isinstance(base_object, str): base_object_str = base_object @@ -100,7 +100,7 @@ def make_polar_array(base_object, doc=App.activeDocument()) if not found: _msg("base_object: {}".format(base_object_str)) - _err(_tr("Wrong input: object not in document.")) + _err(translate("draft","Wrong input: object not in document.")) return None _msg("base_object: {}".format(base_object.Label)) @@ -109,21 +109,21 @@ def make_polar_array(base_object, try: utils.type_check([(number, int)], name=_name) except TypeError: - _err(_tr("Wrong input: must be an integer number.")) + _err(translate("draft","Wrong input: must be an integer number.")) return None _msg("angle: {}".format(angle)) try: utils.type_check([(angle, (int, float))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a number.")) + _err(translate("draft","Wrong input: must be a number.")) return None _msg("center: {}".format(center)) try: utils.type_check([(center, App.Vector)], name=_name) except TypeError: - _err(_tr("Wrong input: must be a vector.")) + _err(translate("draft","Wrong input: must be a vector.")) return None use_link = bool(use_link) diff --git a/src/Mod/Draft/draftmake/make_text.py b/src/Mod/Draft/draftmake/make_text.py index 70d062131c..45ca318af0 100644 --- a/src/Mod/Draft/draftmake/make_text.py +++ b/src/Mod/Draft/draftmake/make_text.py @@ -34,7 +34,7 @@ import draftutils.utils as utils import draftutils.gui_utils as gui_utils from draftutils.messages import _msg, _err -from draftutils.translate import _tr +from draftutils.translate import translate from draftobjects.text import Text if App.GuiUp: @@ -87,20 +87,18 @@ def make_text(string, placement=None, screen=False): found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None _msg("string: {}".format(string)) try: utils.type_check([(string, (str, list))]) except TypeError: - _err(_tr("Wrong input: must be a list of strings " - "or a single string.")) + _err(translate("draft","Wrong input: must be a list of strings or a single string.")) return None if not all(isinstance(element, str) for element in string): - _err(_tr("Wrong input: must be a list of strings " - "or a single string.")) + _err(translate("draft","Wrong input: must be a list of strings or a single string.")) return None if isinstance(string, str): @@ -114,8 +112,7 @@ def make_text(string, placement=None, screen=False): App.Vector, App.Rotation))], name=_name) except TypeError: - _err(_tr("Wrong input: must be a placement, a vector, " - "or a rotation.")) + _err(translate("draft","Wrong input: must be a placement, a vector, or a rotation.")) return None # Convert the vector or rotation to a full placement @@ -180,7 +177,7 @@ def convert_draft_texts(textslist=None): found, doc = utils.find_doc(App.activeDocument()) if not found: - _err(_tr("No active document. Aborting.")) + _err(translate("draft","No active document. Aborting.")) return None if not textslist: diff --git a/src/Mod/Draft/draftobjects/draft_annotation.py b/src/Mod/Draft/draftobjects/draft_annotation.py index 1eec289ea5..180e4dcceb 100644 --- a/src/Mod/Draft/draftobjects/draft_annotation.py +++ b/src/Mod/Draft/draftobjects/draft_annotation.py @@ -40,7 +40,7 @@ through Coin (pivy). from PySide.QtCore import QT_TRANSLATE_NOOP from draftutils.messages import _wrn -from draftutils.translate import _tr +from draftutils.translate import translate class DraftAnnotation(object): @@ -86,19 +86,10 @@ class DraftAnnotation(object): _tip) vobj.ScaleMultiplier = 1.00 - _info = "added view property 'ScaleMultiplier'" - _wrn("v0.19, " + obj.Label + ", " + _tr(_info)) + _wrn("v0.19, " + obj.Label + ", " + translate("draft","added view property 'ScaleMultiplier'")) if 'AnnotationStyle' not in vproperties: - _tip = QT_TRANSLATE_NOOP("App::Property", - "Annotation style to apply " - "to this object.\n" - "When using a saved style " - "some of the view properties " - "will become read-only;\n" - "they will only be editable by changing " - "the style through " - "the 'Annotation style editor' tool.") + _tip = QT_TRANSLATE_NOOP("App::Property","Annotation style to apply to this object.\nWhen using a saved style some of the view properties will become read-only;\nthey will only be editable by changing the style through the 'Annotation style editor' tool.") vobj.addProperty("App::PropertyEnumeration", "AnnotationStyle", "Annotation", @@ -111,7 +102,7 @@ class DraftAnnotation(object): vobj.AnnotationStyle = [""] + styles _info = "added view property 'AnnotationStyle'" - _wrn("v0.19, " + obj.Label + ", " + _tr(_info)) + _wrn("v0.19, " + obj.Label + ", " + translate("draft","added view property 'ScaleMultiplier'")) def __getstate__(self): """Return a tuple of objects to save or None. @@ -131,14 +122,12 @@ class DraftAnnotation(object): # the 'DraftText' type was changed to 'Text' type if state["Type"] == "DraftText": state["Type"] = "Text" - _info = "migrated 'DraftText' type to 'Text'" - _wrn("v0.19, " + _tr(_info)) + _wrn("v0.19, " + translate("draft","migrated 'DraftText' type to 'Text'")) self.Type = state["Type"] else: if state == "DraftText": state = "Text" - _info = "migrated 'DraftText' type to 'Text'" - _wrn("v0.19, " + _tr(_info)) + _wrn("v0.19, " + translate("draft","migrated 'DraftText' type to 'Text'")) self.Type = state def execute(self, obj): diff --git a/src/Mod/Draft/draftobjects/patharray.py b/src/Mod/Draft/draftobjects/patharray.py index 7b134872a3..e85007cd5a 100644 --- a/src/Mod/Draft/draftobjects/patharray.py +++ b/src/Mod/Draft/draftobjects/patharray.py @@ -68,8 +68,8 @@ import DraftVecUtils import lazy_loader.lazy_loader as lz from draftutils.messages import _msg, _wrn, _err -from draftutils.translate import _tr - +from draftutils.translate import translate +def QT_TRANSLATE_NOOP(ctx,txt): return txt from draftobjects.base import DraftObject from draftobjects.draftlink import DraftLink @@ -165,7 +165,7 @@ class PathArray(DraftLink): def set_general_properties(self, obj, properties): """Set general properties only if they don't exist.""" if "Base" not in properties: - _tip = _tr("The base object that will be duplicated") + _tip = QT_TRANSLATE_NOOP("App::Property","The base object that will be duplicated") obj.addProperty("App::PropertyLinkGlobal", "Base", "Objects", @@ -173,9 +173,7 @@ class PathArray(DraftLink): obj.Base = None if "PathObject" not in properties: - _tip = _tr("The object along which " - "the copies will be distributed. " - "It must contain 'Edges'.") + _tip = QT_TRANSLATE_NOOP("App::Property","The object along which the copies will be distributed. It must contain 'Edges'.") obj.addProperty("App::PropertyLinkGlobal", "PathObject", "Objects", @@ -190,11 +188,7 @@ class PathArray(DraftLink): # as this property can be used to select a single object, # or a single object with its subelements. if "PathSubelements" not in properties: - _tip = _tr("List of connected edges in the 'Path Object'.\n" - "If these are present, the copies will be created " - "along these subelements only.\n" - "Leave this property empty to create copies along " - "the entire 'Path Object'.") + _tip = QT_TRANSLATE_NOOP("App::Property","List of connected edges in the 'Path Object'.\nIf these are present, the copies will be created along these subelements only.\nLeave this property empty to create copies along the entire 'Path Object'.") obj.addProperty("App::PropertyLinkSubListGlobal", "PathSubelements", "Objects", @@ -202,7 +196,7 @@ class PathArray(DraftLink): obj.PathSubelements = [] if "Count" not in properties: - _tip = _tr("Number of copies to create") + _tip = QT_TRANSLATE_NOOP("App::Property","Number of copies to create") obj.addProperty("App::PropertyInteger", "Count", "Objects", @@ -210,8 +204,7 @@ class PathArray(DraftLink): obj.Count = 4 if self.use_link and "ExpandArray" not in properties: - _tip = _tr("Show the individual array elements " - "(only for Link arrays)") + _tip = QT_TRANSLATE_NOOP("App::Property","Show the individual array elements (only for Link arrays)") obj.addProperty("App::PropertyBool", "ExpandArray", "Objects", @@ -222,10 +215,7 @@ class PathArray(DraftLink): def set_align_properties(self, obj, properties): """Set general properties only if they don't exist.""" if "ExtraTranslation" not in properties: - _tip = _tr("Additional translation " - "that will be applied to each copy.\n" - "This is useful to adjust for the difference " - "between shape centre and shape reference point.") + _tip = QT_TRANSLATE_NOOP("App::Property","Additional translation that will be applied to each copy.\nThis is useful to adjust for the difference between shape centre and shape reference point.") obj.addProperty("App::PropertyVectorDistance", "ExtraTranslation", "Alignment", @@ -233,7 +223,7 @@ class PathArray(DraftLink): obj.ExtraTranslation = App.Vector(0, 0, 0) if "TangentVector" not in properties: - _tip = _tr("Alignment vector for 'Tangent' mode") + _tip = QT_TRANSLATE_NOOP("App::Property","Alignment vector for 'Tangent' mode") obj.addProperty("App::PropertyVector", "TangentVector", "Alignment", @@ -241,8 +231,7 @@ class PathArray(DraftLink): obj.TangentVector = App.Vector(1, 0, 0) if "ForceVertical" not in properties: - _tip = _tr("Force use of 'Vertical Vector' as local Z direction " - "when using 'Original' or 'Tangent' alignment mode") + _tip = QT_TRANSLATE_NOOP("App::Property","Force use of 'Vertical Vector' as local Z direction when using 'Original' or 'Tangent' alignment mode") obj.addProperty("App::PropertyBool", "ForceVertical", "Alignment", @@ -250,8 +239,7 @@ class PathArray(DraftLink): obj.ForceVertical = False if "VerticalVector" not in properties: - _tip = _tr("Direction of the local Z axis " - "when 'Force Vertical' is true") + _tip = QT_TRANSLATE_NOOP("App::Property","Direction of the local Z axis when 'Force Vertical' is true") obj.addProperty("App::PropertyVector", "VerticalVector", "Alignment", @@ -259,16 +247,7 @@ class PathArray(DraftLink): obj.VerticalVector = App.Vector(0, 0, 1) if "AlignMode" not in properties: - _tip = _tr("Method to orient the copies along the path.\n" - "- Original: X is curve tangent, Y is normal, " - "and Z is the cross product.\n" - "- Frenet: aligns the object following the local " - "coordinate system along the path.\n" - "- Tangent: similar to 'Original' but the local X " - "axis is pre-aligned to 'Tangent Vector'.\n" - "\n" - "To get better results with 'Original' or 'Tangent' " - "you may have to set 'Force Vertical' to true.") + _tip = QT_TRANSLATE_NOOP("App::Property","Method to orient the copies along the path.\n- Original: X is curve tangent, Y is normal, and Z is the cross product.\n- Frenet: aligns the object following the local coordinate system along the path.\n- Tangent: similar to 'Original' but the local X axis is pre-aligned to 'Tangent Vector'.\n\nTo get better results with 'Original' or 'Tangent' you may have to set 'Force Vertical' to true.") obj.addProperty("App::PropertyEnumeration", "AlignMode", "Alignment", @@ -279,10 +258,7 @@ class PathArray(DraftLink): # The Align property must be attached after other align properties # so that onChanged works properly if "Align" not in properties: - _tip = _tr("Orient the copies along the path depending " - "on the 'Align Mode'.\n" - "Otherwise the copies will have the same orientation " - "as the original Base object.") + _tip = QT_TRANSLATE_NOOP("App::Property","Orient the copies along the path depending on the 'Align Mode'.\nOtherwise the copies will have the same orientation as the original Base object.") obj.addProperty("App::PropertyBool", "Align", "Alignment", @@ -305,7 +281,7 @@ class PathArray(DraftLink): w = self.get_wires(obj.PathObject, obj.PathSubelements) if not w: _err(obj.PathObject.Label - + _tr(", path object doesn't have 'Edges'.")) + + translate("draft",", path object doesn't have 'Edges'.")) return base_rotation = obj.Base.Shape.Placement.Rotation @@ -416,20 +392,19 @@ class PathArray(DraftLink): if "PathObj" in properties: obj.PathObject = obj.PathObj obj.removeProperty("PathObj") - _info = "'PathObj' property will be migrated to 'PathObject'" - _wrn("v0.19, " + obj.Label + ", " + _tr(_info)) + _wrn("v0.19, " + obj.Label + ", " + translate("draft","'PathObj' property will be migrated to 'PathObject'")) if "PathSubs" in properties: obj.PathSubelements = obj.PathSubs obj.removeProperty("PathSubs") _info = "'PathSubs' property will be migrated to 'PathSubelements'" - _wrn("v0.19, " + obj.Label + ", " + _tr(_info)) + _wrn("v0.19, " + obj.Label + ", " + translate("draft","'PathObj' property will be migrated to 'PathObject'")) if "Xlate" in properties: obj.ExtraTranslation = obj.Xlate obj.removeProperty("Xlate") _info = "'Xlate' property will be migrated to 'ExtraTranslation'" - _wrn("v0.19, " + obj.Label + ", " + _tr(_info)) + _wrn("v0.19, " + obj.Label + ", " + translate("draft","'PathObj' property will be migrated to 'PathObject'")) # Alias for compatibility with v0.18 and earlier @@ -546,8 +521,8 @@ def calculate_placement(globalRotation, try: t = edge.tangentAt(get_parameter_from_v0(edge, offset)) t.normalize() - except Exception: - _wrn(_tr("Cannot calculate path tangent. Copy not aligned.")) + except: + _wrn(translate("draft","Cannot calculate path tangent. Copy not aligned.")) return placement if mode in ('Original', 'Tangent'): @@ -563,7 +538,7 @@ def calculate_placement(globalRotation, except Exception: # weird special case, tangent and normal parallel b = nullv - _wrn(_tr("Tangent and normal are parallel. Copy not aligned.")) + _wrn(translate("draft","Tangent and normal are parallel. Copy not aligned.")) return placement if overrideNormal: @@ -580,20 +555,20 @@ def calculate_placement(globalRotation, n.normalize() except App.Base.FreeCADError: # no/infinite normals here n = defNormal - _msg(_tr("Cannot calculate path normal, using default.")) + _msg(translate("draft","Cannot calculate path normal, using default.")) try: b = t.cross(n) b.normalize() except Exception: b = nullv - _wrn(_tr("Cannot calculate path binormal. Copy not aligned.")) + _wrn(translate("draft","Cannot calculate path binormal. Copy not aligned.")) return placement priority = "XZY" newRot = App.Rotation(t, n, b, priority) # t/x, n/y, b/z else: - _msg(_tr("AlignMode {} is not implemented".format(mode))) + _msg(translate("draft","AlignMode {} is not implemented").format(mode)) return placement # Have valid tangent, normal, binormal diff --git a/src/Mod/Draft/draftobjects/pathtwistedarray.py b/src/Mod/Draft/draftobjects/pathtwistedarray.py index 605d3a7962..8fd9969bec 100644 --- a/src/Mod/Draft/draftobjects/pathtwistedarray.py +++ b/src/Mod/Draft/draftobjects/pathtwistedarray.py @@ -48,8 +48,8 @@ object in the Arch Workbench. # \brief Provides the object code for the TwistedArray object. import draftgeoutils.geo_arrays as geo -from draftutils.translate import _tr - +from draftutils.translate import translate +def QT_TRANSLATE_NOOP(ctx,txt): return txt from draftobjects.draftlink import DraftLink ## \addtogroup draftobjects @@ -80,46 +80,38 @@ class PathTwistedArray(DraftLink): properties = [] if "Base" not in properties: - _tip = _tr("The base object that will be duplicated.") obj.addProperty("App::PropertyLink", "Base", "Objects", - _tip) + Qt_TRANSLATE_NOOP("App::Property","The base object that will be duplicated.")) obj.Base = None if "PathObject" not in properties: - _tip = _tr("The object along which " - "the copies will be distributed. " - "It must contain 'Edges'.") obj.addProperty("App::PropertyLink", "PathObject", "Objects", - _tip) + Qt_TRANSLATE_NOOP("App::Property","The object along which the copies will be distributed. It must contain 'Edges'.")) obj.PathObject = None if "Count" not in properties: - _tip = _tr("Number of copies to create.") obj.addProperty("App::PropertyInteger", "Count", "Objects", - _tip) + Qt_TRANSLATE_NOOP("App::Property","Number of copies to create.")) obj.Count = 15 if "RotationFactor" not in properties: - _tip = _tr("Rotation factor of the twisted array.") obj.addProperty("App::PropertyFloat", "RotationFactor", "Objects", - _tip) + Qt_TRANSLATE_NOOP("App::Property","Rotation factor of the twisted array.")) obj.RotationFactor = 0.25 if self.use_link and "ExpandArray" not in properties: - _tip = _tr("Show the individual array elements " - "(only for Link arrays)") obj.addProperty("App::PropertyBool", "ExpandArray", "Objects", - _tip) + Qt_TRANSLATE_NOOP("App::Property","Show the individual array elements (only for Link arrays)")) obj.ExpandArray = False obj.setPropertyStatus('Shape', 'Transient') diff --git a/src/Mod/Draft/draftobjects/pointarray.py b/src/Mod/Draft/draftobjects/pointarray.py index 5073efcf8c..f304363aaa 100644 --- a/src/Mod/Draft/draftobjects/pointarray.py +++ b/src/Mod/Draft/draftobjects/pointarray.py @@ -44,7 +44,7 @@ import FreeCAD as App import draftutils.utils as utils from draftutils.messages import _wrn, _err -from draftutils.translate import translate, _tr +from draftutils.translate import translate from draftobjects.draftlink import DraftLink # Delay import of module until first use because it is heavy @@ -75,8 +75,7 @@ class PointArray(DraftLink): properties = obj.PropertiesList if "Base" not in properties: - _tip = QT_TRANSLATE_NOOP("App::Property", - "Base object that will be duplicated") + _tip = QT_TRANSLATE_NOOP("App::Property","Base object that will be duplicated") obj.addProperty("App::PropertyLink", "Base", "Objects", @@ -84,12 +83,7 @@ class PointArray(DraftLink): obj.Base = None if "PointObject" not in properties: - _tip = QT_TRANSLATE_NOOP("App::Property", - ("Object containing points used to distribute " - "the base object, for example, a sketch or " - "a Part compound.\n" - "The sketch or compound must contain at least " - "one explicit point or vertex object.")) + _tip = QT_TRANSLATE_NOOP("App::Property", "Object containing points used to distribute the base object, for example, a sketch or a Part compound.\nThe sketch or compound must contain at least one explicit point or vertex object.") obj.addProperty("App::PropertyLink", "PointObject", "Objects", @@ -97,10 +91,7 @@ class PointArray(DraftLink): obj.PointObject = None if "Count" not in properties: - _tip = QT_TRANSLATE_NOOP("App::Property", - "Total number of elements in the array.\n" - "This property is read-only, as the number depends " - "on the points contained within 'Point Object'.") + _tip = QT_TRANSLATE_NOOP("App::Property","Total number of elements in the array.\nThis property is read-only, as the number depends on the points contained within 'Point Object'.") obj.addProperty("App::PropertyInteger", "Count", "Objects", @@ -109,9 +100,7 @@ class PointArray(DraftLink): obj.setEditorMode("Count", 1) # Read only if "ExtraPlacement" not in properties: - _tip = QT_TRANSLATE_NOOP("App::Property", - "Additional placement, shift and rotation, " - "that will be applied to each copy") + _tip = QT_TRANSLATE_NOOP("App::Property","Additional placement, shift and rotation, that will be applied to each copy") obj.addProperty("App::PropertyPlacement", "ExtraPlacement", "Objects", @@ -119,8 +108,7 @@ class PointArray(DraftLink): obj.ExtraPlacement = App.Placement() if self.use_link and "ExpandArray" not in properties: - _tip = _tr("Show the individual array elements " - "(only for Link arrays)") + _tip = QT_TRANSLATE_NOOP("App::Property","Show the individual array elements (only for Link arrays)") obj.addProperty("App::PropertyBool", "ExpandArray", "Objects", @@ -147,15 +135,13 @@ class PointArray(DraftLink): properties = obj.PropertiesList if "ExtraPlacement" not in properties: - _tip = QT_TRANSLATE_NOOP("App::Property", "Additional placement, shift and rotation, " - "that will be applied to each copy") + _tip = QT_TRANSLATE_NOOP("App::Property", "Additional placement, shift and rotation, that will be applied to each copy") obj.addProperty("App::PropertyPlacement", "ExtraPlacement", "Objects", _tip) obj.ExtraPlacement.Base = obj.Base.Placement.Base - _info = "added property 'ExtraPlacement'" - _wrn("v0.19, " + obj.Label + ", " + _tr(_info)) + _wrn("v0.19, " + obj.Label + ", " + translate("draft","added property 'ExtraPlacement'")) self.set_properties(obj) self.migrate_properties_0v19(obj) @@ -171,7 +157,7 @@ class PointArray(DraftLink): obj.PointObject = obj.PointList obj.removeProperty("PointList") _info = "'PointList' property will be migrated to 'PointObject'" - _wrn("v0.19, " + obj.Label + ", " + _tr(_info)) + _wrn("v0.19, " + obj.Label + ", " + translate("draft","added property 'ExtraPlacement'")) def get_point_list(point_object): diff --git a/src/Mod/Draft/drafttaskpanels/task_circulararray.py b/src/Mod/Draft/drafttaskpanels/task_circulararray.py index e340d2b206..a815c4e56c 100644 --- a/src/Mod/Draft/drafttaskpanels/task_circulararray.py +++ b/src/Mod/Draft/drafttaskpanels/task_circulararray.py @@ -38,7 +38,7 @@ import draftutils.utils as utils from FreeCAD import Units as U from draftutils.messages import _msg, _wrn, _err, _log -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) bool(Draft_rc.__name__) @@ -80,7 +80,7 @@ class TaskPanelCircularArray: def __init__(self): self.name = "Circular array" - _log(_tr("Task panel:") + " {}".format(_tr(self.name))) + _log(translate("draft","Task panel:") + " {}".format(translate("draft","Circular array"))) # The .ui file must be loaded into an attribute # called `self.form` so that it is displayed in the task panel. @@ -92,7 +92,7 @@ class TaskPanelCircularArray: pix = QtGui.QPixmap(svg) icon = QtGui.QIcon.fromTheme(icon_name, QtGui.QIcon(svg)) self.form.setWindowIcon(icon) - self.form.setWindowTitle(_tr(self.name)) + self.form.setWindowTitle(translate("draft","Circular array")) self.form.label_icon.setPixmap(pix.scaled(32, 32)) @@ -215,35 +215,32 @@ class TaskPanelCircularArray: the interface may not allow to input wrong data. """ if not selection: - _err(_tr("At least one element must be selected.")) + _err(translate("draft","At least one element must be selected.")) return False if number < 2: - _err(_tr("Number of layers must be at least 2.")) + _err(translate("draft","Number of layers must be at least 2.")) return False # TODO: this should handle multiple objects. # Each of the elements of the selection should be tested. obj = selection[0] if obj.isDerivedFrom("App::FeaturePython"): - _err(_tr("Selection is not suitable for array.")) - _err(_tr("Object:") + " {}".format(selection[0].Label)) + _err(translate("draft","Selection is not suitable for array.")) + _err(translate("draft","Object:") + " {}".format(selection[0].Label)) return False if r_distance == 0: - _wrn(_tr("Radial distance is zero. " - "Resulting array may not look correct.")) + _wrn(translate("draft","Radial distance is zero. Resulting array may not look correct.")) elif r_distance < 0: - _wrn(_tr("Radial distance is negative. " - "It is made positive to proceed.")) + _wrn(translate("draft","Radial distance is negative. It is made positive to proceed.")) self.r_distance = abs(r_distance) if tan_distance == 0: - _err(_tr("Tangential distance cannot be zero.")) + _err(translate("draft","Tangential distance cannot be zero.")) return False elif tan_distance < 0: - _wrn(_tr("Tangential distance is negative. " - "It is made positive to proceed.")) + _wrn(translate("draft","Tangential distance is negative. It is made positive to proceed.")) self.tan_distance = abs(tan_distance) # The other arguments are not tested but they should be present. @@ -300,7 +297,7 @@ class TaskPanelCircularArray: "App.ActiveDocument.recompute()"] # We commit the command list through the parent command - self.source_command.commit(_tr(self.name), _cmd_list) + self.source_command.commit(translate("draft","Circular array", _cmd_list) def get_distances(self): """Get the distance parameters from the widgets.""" @@ -340,7 +337,7 @@ class TaskPanelCircularArray: self.form.input_c_z.setProperty('rawValue', 0) self.center = self.get_center() - _msg(_tr("Center reset:") + _msg(translate("draft","Center reset:") + " ({0}, {1}, {2})".format(self.center.x, self.center.y, self.center.z)) @@ -351,7 +348,7 @@ class TaskPanelCircularArray: state = self.tr_true else: state = self.tr_false - _msg(_tr("Fuse:") + " {}".format(state)) + _msg(translate("draft","Fuse:") + " {}".format(state)) def set_fuse(self): """Execute as a callback when the fuse checkbox changes.""" @@ -365,7 +362,7 @@ class TaskPanelCircularArray: state = self.tr_true else: state = self.tr_false - _msg(_tr("Create Link array:") + " {}".format(state)) + _msg(translate("draft","Create Link array:") + " {}".format(state)) def set_link(self): """Execute as a callback when the link checkbox changes.""" @@ -382,12 +379,12 @@ class TaskPanelCircularArray: # For example, it could take the shapes of all objects, # make a compound and then use it as input for the array function. sel_obj = self.selection[0] - _msg(_tr("Object:") + " {}".format(sel_obj.Label)) - _msg(_tr("Radial distance:") + " {}".format(self.r_distance)) - _msg(_tr("Tangential distance:") + " {}".format(self.tan_distance)) - _msg(_tr("Number of circular layers:") + " {}".format(self.number)) - _msg(_tr("Symmetry parameter:") + " {}".format(self.symmetry)) - _msg(_tr("Center of rotation:") + _msg(translate("draft","Object:") + " {}".format(sel_obj.Label)) + _msg(translate("draft","Radial distance:") + " {}".format(self.r_distance)) + _msg(translate("draft","Tangential distance:") + " {}".format(self.tan_distance)) + _msg(translate("draft","Number of circular layers:") + " {}".format(self.number)) + _msg(translate("draft","Symmetry parameter:") + " {}".format(self.symmetry)) + _msg(translate("draft","Center of rotation:") + " ({0}, {1}, {2})".format(self.center.x, self.center.y, self.center.z)) @@ -491,7 +488,7 @@ class TaskPanelCircularArray: def reject(self): """Execute when clicking the Cancel button or pressing Escape.""" - _msg(_tr("Aborted:") + " {}".format(_tr(self.name))) + _msg(translate("draft","Aborted:") + " {}".format(translate("draft","Circular array"))) self.finish() def finish(self): diff --git a/src/Mod/Draft/drafttaskpanels/task_orthoarray.py b/src/Mod/Draft/drafttaskpanels/task_orthoarray.py index 39b634ee69..08c056c0cc 100644 --- a/src/Mod/Draft/drafttaskpanels/task_orthoarray.py +++ b/src/Mod/Draft/drafttaskpanels/task_orthoarray.py @@ -38,7 +38,7 @@ import draftutils.utils as utils from FreeCAD import Units as U from draftutils.messages import _msg, _err, _log -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) bool(Draft_rc.__name__) @@ -80,7 +80,7 @@ class TaskPanelOrthoArray: def __init__(self): self.name = "Orthogonal array" - _log(_tr("Task panel:") + " {}".format(_tr(self.name))) + _log(translate("draft","Task panel:") + " {}".format(translate("draft","Orthogonal array"))) # The .ui file must be loaded into an attribute # called `self.form` so that it is displayed in the task panel. @@ -92,7 +92,7 @@ class TaskPanelOrthoArray: pix = QtGui.QPixmap(svg) icon = QtGui.QIcon.fromTheme(icon_name, QtGui.QIcon(svg)) self.form.setWindowIcon(icon) - self.form.setWindowTitle(_tr(self.name)) + self.form.setWindowTitle(translate("draft","Orthogonal array")) self.form.label_icon.setPixmap(pix.scaled(32, 32)) @@ -202,19 +202,19 @@ class TaskPanelOrthoArray: the interface may not allow to input wrong data. """ if not selection: - _err(_tr("At least one element must be selected.")) + _err(translate("draft","At least one element must be selected.")) return False if n_x < 1 or n_y < 1 or n_z < 1: - _err(_tr("Number of elements must be at least 1.")) + _err(translate("draft","Number of elements must be at least 1.")) return False # TODO: this should handle multiple objects. # Each of the elements of the selection should be tested. obj = selection[0] if obj.isDerivedFrom("App::FeaturePython"): - _err(_tr("Selection is not suitable for array.")) - _err(_tr("Object:") + " {0} ({1})".format(obj.Label, obj.TypeId)) + _err(translate("draft","Selection is not suitable for array.")) + _err(translate("draft","Object:") + " {0} ({1})".format(obj.Label, obj.TypeId)) return False # The other arguments are not tested but they should be present. @@ -270,7 +270,7 @@ class TaskPanelOrthoArray: "App.ActiveDocument.recompute()"] # We commit the command list through the parent command - self.source_command.commit(_tr(self.name), _cmd_list) + self.source_command.commit(translate("draft","Orthogonal array"), _cmd_list) def get_numbers(self): """Get the number of elements from the widgets.""" @@ -316,7 +316,7 @@ class TaskPanelOrthoArray: self.form.input_X_y.setProperty('rawValue', 0) self.form.input_X_z.setProperty('rawValue', 0) self.v_x, self.v_y, self.v_z = self.get_intervals() - _msg(_tr("Interval X reset:") + _msg(translate("draft","Interval X reset:") + " ({0}, {1}, {2})".format(self.v_x.x, self.v_x.y, self.v_x.z)) @@ -325,7 +325,7 @@ class TaskPanelOrthoArray: self.form.input_Y_y.setProperty('rawValue', 100) self.form.input_Y_z.setProperty('rawValue', 0) self.v_x, self.v_y, self.v_z = self.get_intervals() - _msg(_tr("Interval Y reset:") + _msg(translate("draft","Interval Y reset:") + " ({0}, {1}, {2})".format(self.v_y.x, self.v_y.y, self.v_y.z)) @@ -334,7 +334,7 @@ class TaskPanelOrthoArray: self.form.input_Z_y.setProperty('rawValue', 0) self.form.input_Z_z.setProperty('rawValue', 100) self.v_x, self.v_y, self.v_z = self.get_intervals() - _msg(_tr("Interval Z reset:") + _msg(translate("draft","Interval Z reset:") + " ({0}, {1}, {2})".format(self.v_z.x, self.v_z.y, self.v_z.z)) @@ -345,7 +345,7 @@ class TaskPanelOrthoArray: state = self.tr_true else: state = self.tr_false - _msg(_tr("Fuse:") + " {}".format(state)) + _msg(translate("draft","Fuse:") + " {}".format(state)) def set_fuse(self): """Execute as a callback when the fuse checkbox changes.""" @@ -359,7 +359,7 @@ class TaskPanelOrthoArray: state = self.tr_true else: state = self.tr_false - _msg(_tr("Create Link array:") + " {}".format(state)) + _msg(translate("draft","Create Link array:") + " {}".format(state)) def set_link(self): """Execute as a callback when the link checkbox changes.""" @@ -376,19 +376,19 @@ class TaskPanelOrthoArray: # For example, it could take the shapes of all objects, # make a compound and then use it as input for the array function. sel_obj = self.selection[0] - _msg(_tr("Object:") + " {}".format(sel_obj.Label)) - _msg(_tr("Number of X elements:") + " {}".format(self.n_x)) - _msg(_tr("Interval X:") + _msg(translate("draft","Object:") + " {}".format(sel_obj.Label)) + _msg(translate("draft","Number of X elements:") + " {}".format(self.n_x)) + _msg(translate("draft","Interval X:") + " ({0}, {1}, {2})".format(self.v_x.x, self.v_x.y, self.v_x.z)) - _msg(_tr("Number of Y elements:") + " {}".format(self.n_y)) - _msg(_tr("Interval Y:") + _msg(translate("draft","Number of Y elements:") + " {}".format(self.n_y)) + _msg(translate("draft","Interval Y:") + " ({0}, {1}, {2})".format(self.v_y.x, self.v_y.y, self.v_y.z)) - _msg(_tr("Number of Z elements:") + " {}".format(self.n_z)) - _msg(_tr("Interval Z:") + _msg(translate("draft","Number of Z elements:") + " {}".format(self.n_z)) + _msg(translate("draft","Interval Z:") + " ({0}, {1}, {2})".format(self.v_z.x, self.v_z.y, self.v_z.z)) @@ -397,7 +397,7 @@ class TaskPanelOrthoArray: def reject(self): """Execute when clicking the Cancel button or pressing Escape.""" - _msg(_tr("Aborted:") + " {}".format(_tr(self.name))) + _msg(translate("draft","Aborted:") + " {}".format(translate("draft","Orthogonal array"))) self.finish() def finish(self): diff --git a/src/Mod/Draft/drafttaskpanels/task_polararray.py b/src/Mod/Draft/drafttaskpanels/task_polararray.py index 66162b2a8e..0258a9dbf9 100644 --- a/src/Mod/Draft/drafttaskpanels/task_polararray.py +++ b/src/Mod/Draft/drafttaskpanels/task_polararray.py @@ -38,7 +38,7 @@ import draftutils.utils as utils from FreeCAD import Units as U from draftutils.messages import _msg, _wrn, _err, _log -from draftutils.translate import _tr +from draftutils.translate import translate # The module is used to prevent complaints from code checkers (flake8) bool(Draft_rc.__name__) @@ -80,7 +80,7 @@ class TaskPanelPolarArray: def __init__(self): self.name = "Polar array" - _log(_tr("Task panel:") + " {}".format(_tr(self.name))) + _log(translate("draft","Task panel:") + " {}".format(self.name)) # The .ui file must be loaded into an attribute # called `self.form` so that it is displayed in the task panel. @@ -92,7 +92,7 @@ class TaskPanelPolarArray: pix = QtGui.QPixmap(svg) icon = QtGui.QIcon.fromTheme(icon_name, QtGui.QIcon(svg)) self.form.setWindowIcon(icon) - self.form.setWindowTitle(_tr(self.name)) + self.form.setWindowTitle(translate("draft","Polar array") self.form.label_icon.setPixmap(pix.scaled(32, 32)) @@ -188,28 +188,26 @@ class TaskPanelPolarArray: the interface may not allow to input wrong data. """ if not selection: - _err(_tr("At least one element must be selected.")) + _err(translate("draft","At least one element must be selected.")) return False # TODO: this should handle multiple objects. # Each of the elements of the selection should be tested. obj = selection[0] if obj.isDerivedFrom("App::FeaturePython"): - _err(_tr("Selection is not suitable for array.")) - _err(_tr("Object:") + " {}".format(selection[0].Label)) + _err(translate("draft","Selection is not suitable for array.")) + _err(translate("draft","Object:") + " {}".format(selection[0].Label)) return False if number < 2: - _err(_tr("Number of elements must be at least 2.")) + _err(translate("draft","Number of elements must be at least 2.")) return False if angle > 360: - _wrn(_tr("The angle is above 360 degrees. " - "It is set to this value to proceed.")) + _wrn(translate("draft","The angle is above 360 degrees. It is set to this value to proceed.")) self.angle = 360 elif angle < -360: - _wrn(_tr("The angle is below -360 degrees. " - "It is set to this value to proceed.")) + _wrn(translate("draft","The angle is below -360 degrees. It is set to this value to proceed.")) self.angle = -360 # The other arguments are not tested but they should be present. @@ -261,7 +259,7 @@ class TaskPanelPolarArray: "App.ActiveDocument.recompute()"] # We commit the command list through the parent command - self.source_command.commit(_tr(self.name), _cmd_list) + self.source_command.commit(translate("draft","Polar array"), _cmd_list) def get_number_angle(self): """Get the number and angle parameters from the widgets.""" @@ -288,7 +286,7 @@ class TaskPanelPolarArray: self.form.input_c_z.setProperty('rawValue', 0) self.center = self.get_center() - _msg(_tr("Center reset:") + _msg(translate("draft","Center reset:") + " ({0}, {1}, {2})".format(self.center.x, self.center.y, self.center.z)) @@ -299,7 +297,7 @@ class TaskPanelPolarArray: state = self.tr_true else: state = self.tr_false - _msg(_tr("Fuse:") + " {}".format(state)) + _msg(translate("draft","Fuse:") + " {}".format(state)) def set_fuse(self): """Execute as a callback when the fuse checkbox changes.""" @@ -313,7 +311,7 @@ class TaskPanelPolarArray: state = self.tr_true else: state = self.tr_false - _msg(_tr("Create Link array:") + " {}".format(state)) + _msg(translate("draft","Create Link array:") + " {}".format(state)) def set_link(self): """Execute as a callback when the link checkbox changes.""" @@ -330,10 +328,10 @@ class TaskPanelPolarArray: # For example, it could take the shapes of all objects, # make a compound and then use it as input for the array function. sel_obj = self.selection[0] - _msg(_tr("Object:") + " {}".format(sel_obj.Label)) - _msg(_tr("Number of elements:") + " {}".format(self.number)) - _msg(_tr("Polar angle:") + " {}".format(self.angle)) - _msg(_tr("Center of rotation:") + _msg(translate("draft","Object:") + " {}".format(sel_obj.Label)) + _msg(translate("draft","Number of elements:") + " {}".format(self.number)) + _msg(translate("draft","Polar angle:") + " {}".format(self.angle)) + _msg(translate("draft","Center of rotation:") + " ({0}, {1}, {2})".format(self.center.x, self.center.y, self.center.z)) @@ -437,7 +435,7 @@ class TaskPanelPolarArray: def reject(self): """Execute when clicking the Cancel button or pressing Escape.""" - _msg(_tr("Aborted:") + " {}".format(_tr(self.name))) + _msg(translate("draft","Aborted:") + " {}".format(translate("draft","Polar array"))) self.finish() def finish(self):