diff --git a/freecad/gears/basegear.py b/freecad/gears/basegear.py index 4623a36..856ed4c 100644 --- a/freecad/gears/basegear.py +++ b/freecad/gears/basegear.py @@ -23,10 +23,11 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears import __version__ from pygears._functions import arc_from_points_and_center +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + def fcvec(x): """tranforms a list or numpy array to a FreeCAD Vector which is @@ -100,7 +101,7 @@ def __init__(self, obj): "App::PropertyString", "version", "version", - translate("BaseGear", "freecad.gears-version"), + QT_TRANSLATE_NOOP("App::Property", "freecad.gears-version"), 1, ) obj.version = __version__ diff --git a/freecad/gears/bevelgear.py b/freecad/gears/bevelgear.py index 48d1bf3..7331d2b 100644 --- a/freecad/gears/bevelgear.py +++ b/freecad/gears/bevelgear.py @@ -20,12 +20,14 @@ from freecad import part import numpy as np -from .translateutils import translate + from pygears.bevel_tooth import BevelTooth from pygears._functions import rotation3D from .basegear import BaseGear, fcvec, make_bspline_wire +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class BevelGear(BaseGear): """parameters: @@ -40,50 +42,50 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("BevelGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("BevelGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyAngle", "pitch_angle", "involute", - translate("BevelGear", "pitch_angle"), + QT_TRANSLATE_NOOP("App::Property", "pitch_angle"), ) obj.addProperty( "App::PropertyAngle", "pressure_angle", "involute_parameter", - translate("BevelGear", "pressure_angle"), + QT_TRANSLATE_NOOP("App::Property", "pressure_angle"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate("BevelGear", "module"), + QT_TRANSLATE_NOOP("App::Property", "module"), ) obj.addProperty( "App::PropertyFloat", "clearance", "tolerance", - translate("BevelGear", "clearance"), + QT_TRANSLATE_NOOP("App::Property", "clearance"), ) obj.addProperty( "App::PropertyInteger", "numpoints", "precision", - translate("BevelGear", "number of points for spline"), + QT_TRANSLATE_NOOP("App::Property", "number of points for spline"), ) obj.addProperty( "App::PropertyBool", "reset_origin", "base", - translate( - "BevelGear", + QT_TRANSLATE_NOOP( + "App::Property", "if value is true the gears outer face will match the z=0 plane", ), ) @@ -91,8 +93,8 @@ def __init__(self, obj): "App::PropertyLength", "backlash", "tolerance", - translate( - "BevelGear", + QT_TRANSLATE_NOOP( + "App::Property", "The arc length on the pitch circle by which the tooth thicknes is reduced.", ), ) @@ -100,19 +102,19 @@ def __init__(self, obj): "App::PropertyPythonObject", "gear", "base", - translate("BevelGear", "test"), + QT_TRANSLATE_NOOP("App::Property", "test"), ) obj.addProperty( "App::PropertyAngle", "beta", "helical", - translate("BevelGear", "angle used for spiral bevel-gears"), + QT_TRANSLATE_NOOP("App::Property", "angle used for spiral bevel-gears"), ) obj.addProperty( "App::PropertyLength", "dw", "computed", - translate("BevelGear", "The pitch diameter."), + QT_TRANSLATE_NOOP("App::Property", "The pitch diameter."), ) obj.setExpression( "dw", "num_teeth * module" @@ -124,8 +126,8 @@ def __init__(self, obj): "App::PropertyAngle", "angular_backlash", "computed", - translate( - "BevelGear", + QT_TRANSLATE_NOOP( + "App::Property", "The angle by which this gear can turn without moving the mating gear.", ), ) diff --git a/freecad/gears/commands.py b/freecad/gears/commands.py index 5016ef3..ed7b9ac 100644 --- a/freecad/gears/commands.py +++ b/freecad/gears/commands.py @@ -20,8 +20,6 @@ from freecad import app from freecad import gui -from .translateutils import translate - from .basegear import ViewProviderGear, BaseGear from .timinggear_t import TimingGearT @@ -40,6 +38,8 @@ from .connector import GearConnector, ViewProviderGearConnector +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class BaseCommand(object): NAME = "" @@ -101,115 +101,127 @@ class CreateInvoluteGear(BaseCommand): NAME = "InvoluteGear" GEAR_FUNCTION = InvoluteGear Pixmap = os.path.join(BaseCommand.ICONDIR, "involutegear.svg") - MenuText = translate("Commands", "Involute Gear") - ToolTip = translate("Commands", "Create an external involute gear") + MenuText = QT_TRANSLATE_NOOP("FCGear_InvoluteGear", "Involute Gear") + ToolTip = QT_TRANSLATE_NOOP( + "FCGear_InvoluteGear", "Create an external involute gear" + ) class CreateInternalInvoluteGear(BaseCommand): NAME = "InternalInvoluteGear" GEAR_FUNCTION = InternalInvoluteGear Pixmap = os.path.join(BaseCommand.ICONDIR, "internalinvolutegear.svg") - MenuText = translate("Commands", "Internal Involute Gear") - ToolTip = translate("Commands", "Create an internal involute gear") + MenuText = QT_TRANSLATE_NOOP( + "FCGear_InternalInvoluteGear", "Internal Involute Gear" + ) + ToolTip = QT_TRANSLATE_NOOP( + "FCGear_InternalInvoluteGear", "Create an internal involute gear" + ) class CreateInvoluteRack(BaseCommand): NAME = "InvoluteRack" GEAR_FUNCTION = InvoluteGearRack Pixmap = os.path.join(BaseCommand.ICONDIR, "involuterack.svg") - MenuText = translate("Commands", "Involute Rack") - ToolTip = translate("Commands", "Create an Involute rack") + MenuText = QT_TRANSLATE_NOOP("FCGear_InvoluteRack", "Involute Rack") + ToolTip = QT_TRANSLATE_NOOP("FCGear_InvoluteRack", "Create an Involute rack") class CreateCycloidRack(BaseCommand): NAME = "CycloidRack" GEAR_FUNCTION = CycloidGearRack Pixmap = os.path.join(BaseCommand.ICONDIR, "cycloidrack.svg") - MenuText = translate("Commands", "Cycloid Rack") - ToolTip = translate("Commands", "Create an Cycloid rack") + MenuText = QT_TRANSLATE_NOOP("FCGear_CycloidRack", "Cycloid Rack") + ToolTip = QT_TRANSLATE_NOOP("FCGear_CycloidRack", "Create an Cycloid rack") class CreateCrownGear(BaseCommand): NAME = "CrownGear" GEAR_FUNCTION = CrownGear Pixmap = os.path.join(BaseCommand.ICONDIR, "crowngear.svg") - MenuText = translate("Commands", "Crown Gear") - ToolTip = translate("Commands", "Create a Crown gear") + MenuText = QT_TRANSLATE_NOOP("FCGear_CrownGear", "Crown Gear") + ToolTip = QT_TRANSLATE_NOOP("FCGear_CrownGear", "Create a Crown gear") class CreateCycloidGear(BaseCommand): NAME = "CycloidGear" GEAR_FUNCTION = CycloidGear Pixmap = os.path.join(BaseCommand.ICONDIR, "cycloidgear.svg") - MenuText = translate("Commands", "Cycloid Gear") - ToolTip = translate("Commands", "Create a Cycloid gear") + MenuText = QT_TRANSLATE_NOOP("FCGear_CycloidGear", "Cycloid Gear") + ToolTip = QT_TRANSLATE_NOOP("FCGear_CycloidGear", "Create a Cycloid gear") class CreateBevelGear(BaseCommand): NAME = "BevelGear" GEAR_FUNCTION = BevelGear Pixmap = os.path.join(BaseCommand.ICONDIR, "bevelgear.svg") - MenuText = translate("Commands", "Bevel Gear") - ToolTip = translate("Commands", "Create a Bevel gear") + MenuText = QT_TRANSLATE_NOOP("FCGear_BevelGear", "Bevel Gear") + ToolTip = QT_TRANSLATE_NOOP("FCGear_BevelGear", "Create a Bevel gear") class CreateHypoCycloidGear(BaseCommand): NAME = "HypocycloidGear" GEAR_FUNCTION = HypoCycloidGear Pixmap = os.path.join(BaseCommand.ICONDIR, "hypocycloidgear.svg") - MenuText = translate("Commands", "HypoCycloid Gear") - ToolTip = translate("Commands", "Create a HypoCycloid gear with its pins") + MenuText = QT_TRANSLATE_NOOP("FCGear_HypoCycloidGear", "HypoCycloid Gear") + ToolTip = QT_TRANSLATE_NOOP( + "FCGear_HypoCycloidGear", "Create a HypoCycloid gear with its pins" + ) class CreateWormGear(BaseCommand): NAME = "WormGear" GEAR_FUNCTION = WormGear Pixmap = os.path.join(BaseCommand.ICONDIR, "wormgear.svg") - MenuText = translate("Commands", "Worm Gear") - ToolTip = translate("Commands", "Create a Worm gear") + MenuText = QT_TRANSLATE_NOOP("FCGear_WormGear", "Worm Gear") + ToolTip = QT_TRANSLATE_NOOP("FCGear_WormGear", "Create a Worm gear") class CreateTimingGearT(BaseCommand): NAME = "TimingGearT" GEAR_FUNCTION = TimingGearT Pixmap = os.path.join(BaseCommand.ICONDIR, "timinggear_t.svg") - MenuText = translate("Commands", "Timing Gear T-shape") - ToolTip = translate("Commands", "Create a Timing gear T-shape") + MenuText = QT_TRANSLATE_NOOP("FCGear_TimingGearT", "Timing Gear T-shape") + ToolTip = QT_TRANSLATE_NOOP("FCGear_TimingGearT", "Create a Timing gear T-shape") class CreateTimingGear(BaseCommand): NAME = "TimingGear" GEAR_FUNCTION = TimingGear Pixmap = os.path.join(BaseCommand.ICONDIR, "timinggear.svg") - MenuText = translate("Commands", "Timing Gear") - ToolTip = translate("Commands", "Create a Timing gear") + MenuText = QT_TRANSLATE_NOOP("FCGear_TimingGear", "Timing Gear") + ToolTip = QT_TRANSLATE_NOOP("FCGear_TimingGear", "Create a Timing gear") class CreateLanternGear(BaseCommand): NAME = "LanternGear" GEAR_FUNCTION = LanternGear Pixmap = os.path.join(BaseCommand.ICONDIR, "lanterngear.svg") - MenuText = translate("Commands", "Lantern Gear") - ToolTip = translate("Commands", "Create a Lantern gear") + MenuText = QT_TRANSLATE_NOOP("FCGear_LanternGear", "Lantern Gear") + ToolTip = QT_TRANSLATE_NOOP("FCGear_LanternGear", "Create a Lantern gear") class CreateGearConnector(BaseCommand): NAME = "GearConnector" GEAR_FUNCTION = GearConnector Pixmap = os.path.join(BaseCommand.ICONDIR, "gearconnector.svg") - MenuText = translate("Commands", "Combine two gears") - ToolTip = translate("Commands", "Combine two gears") + MenuText = QT_TRANSLATE_NOOP("FCGear_GearConnector", "Combine two gears") + ToolTip = QT_TRANSLATE_NOOP("FCGear_GearConnector", "Combine two gears") def Activated(self): try: selection = gui.Selection.getSelection() if len(selection) != 2: - raise ValueError("Please select two gear objects.") + raise ValueError( + app.Qt.translate("Log", "Please select two gear objects.") + ) for obj in selection: if not isinstance(obj.Proxy, BaseGear): - raise TypeError("Selected object is not a gear.") + raise TypeError( + app.Qt.translate("Log", "Selected object is not a gear.") + ) obj = app.ActiveDocument.addObject("Part::FeaturePython", self.NAME) GearConnector(obj, selection[0], selection[1]) diff --git a/freecad/gears/connector.py b/freecad/gears/connector.py index d6b00a1..2ab11bf 100644 --- a/freecad/gears/connector.py +++ b/freecad/gears/connector.py @@ -25,13 +25,14 @@ from pygears import __version__ from pygears.computation import compute_shifted_gears -from .translateutils import translate from .involutegear import InvoluteGear from .internalinvolutegear import InternalInvoluteGear from .involutegearrack import InvoluteGearRack from .cycloidgear import CycloidGear from .cycloidgearrack import CycloidGearRack +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class ViewProviderGearConnector(object): def __init__(self, vobj, icon_fn=None): @@ -68,35 +69,35 @@ def __init__(self, obj, master_gear, slave_gear): "App::PropertyString", "version", "version", - translate("GearConnector", "freecad.gears-version"), + QT_TRANSLATE_NOOP("App::Property", "freecad.gears-version"), 1, ) obj.addProperty( "App::PropertyLink", "master_gear", "gear", - translate("GearConnector", "master gear"), + QT_TRANSLATE_NOOP("App::Property", "master gear"), 1, ) obj.addProperty( "App::PropertyLink", "slave_gear", "gear", - translate("GearConnector", "slave gear"), + QT_TRANSLATE_NOOP("App::Property", "slave gear"), 1, ) obj.addProperty( "App::PropertyAngle", "angle1", "gear", - translate("GearConnector", "angle at which second gear is placed"), + QT_TRANSLATE_NOOP("App::Property", "angle at which second gear is placed"), 0, ) obj.addProperty( "App::PropertyAngle", "angle2", "gear", - translate("GearConnector", "angle at which second gear is placed"), + QT_TRANSLATE_NOOP("App::Property", "angle at which second gear is placed"), 1, ) obj.version = __version__ diff --git a/freecad/gears/crowngear.py b/freecad/gears/crowngear.py index 8903207..158c984 100644 --- a/freecad/gears/crowngear.py +++ b/freecad/gears/crowngear.py @@ -22,9 +22,10 @@ from freecad import app from freecad import part -from .translateutils import translate from .basegear import BaseGear, fcvec +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class CrownGear(BaseGear): """ @@ -40,37 +41,37 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("CrownGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyInteger", "other_teeth", "base", - translate("CrownGear", "number of teeth of other gear"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth of other gear"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate("CrownGear", "module"), + QT_TRANSLATE_NOOP("App::Property", "module"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("CrownGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyLength", "thickness", "base", - translate("CrownGear", "thickness"), + QT_TRANSLATE_NOOP("App::Property", "thickness"), ) obj.addProperty( "App::PropertyAngle", "pressure_angle", "involute", - translate("CrownGear", "pressure angle"), + QT_TRANSLATE_NOOP("App::Property", "pressure angle"), ) self.add_accuracy_properties(obj) obj.num_teeth = 15 @@ -85,8 +86,11 @@ def __init__(self, obj): obj.Proxy = self app.Console.PrintMessage( - "Gear module: Crown gear created, preview_mode = true for improved performance. " - "Set preview_mode property to false when ready to cut teeth." + app.Qt.translate( + "Log", + "Gear module: Crown gear created, preview_mode = true for improved performance. " + "Set preview_mode property to false when ready to cut teeth.", + ) ) def add_accuracy_properties(self, obj): @@ -94,13 +98,13 @@ def add_accuracy_properties(self, obj): "App::PropertyInteger", "num_profiles", "accuracy", - translate("CrownGear", "number of profiles used for loft"), + QT_TRANSLATE_NOOP("App::Property", "number of profiles used for loft"), ) obj.addProperty( "App::PropertyBool", "preview_mode", "accuracy", - translate("CrownGear", "if true no boolean operation is done"), + QT_TRANSLATE_NOOP("App::Property", "if true no boolean operation is done"), ) def profile(self, m, r, r0, t_c, t_i, alpha_w, y0, y1, y2): diff --git a/freecad/gears/cycloidgear.py b/freecad/gears/cycloidgear.py index 4e93d97..fa6e859 100644 --- a/freecad/gears/cycloidgear.py +++ b/freecad/gears/cycloidgear.py @@ -20,7 +20,6 @@ from freecad import part import numpy as np -from .translateutils import translate from pygears.cycloid_tooth import CycloidTooth from pygears._functions import rotation @@ -32,6 +31,8 @@ rotate_tooth, ) +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class CycloidGear(BaseGear): """FreeCAD gear""" @@ -43,31 +44,31 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("CycloidGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate("CycloidGear", "module"), + QT_TRANSLATE_NOOP("App::Property", "module"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("CycloidGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyInteger", "numpoints", "accuracy", - translate("CycloidGear", "number of points for spline"), + QT_TRANSLATE_NOOP("App::Property", "number of points for spline"), ) obj.addProperty( "App::PropertyPythonObject", "gear", "base", - translate("CycloidGear", "the python object"), + QT_TRANSLATE_NOOP("App::Property", "the python object"), ) self.add_helical_properties(obj) @@ -98,13 +99,13 @@ def add_helical_properties(self, obj): "App::PropertyBool", "double_helix", "helical", - translate("CycloidGear", "double helix"), + QT_TRANSLATE_NOOP("App::Property", "double helix"), ) obj.addProperty( "App::PropertyAngle", "beta", "helical", - translate("CycloidGear", "beta"), + QT_TRANSLATE_NOOP("App::Property", "beta"), ) def add_fillet_properties(self, obj): @@ -112,8 +113,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "head_fillet", "fillets", - translate( - "CycloidGear", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), ) @@ -121,8 +122,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "root_fillet", "fillets", - translate( - "CycloidGear", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), ) @@ -132,14 +133,14 @@ def add_tolerance_properties(self, obj): "App::PropertyFloat", "clearance", "tolerance", - translate("CycloidGear", "clearance"), + QT_TRANSLATE_NOOP("App::Property", "clearance"), ) obj.addProperty( "App::PropertyLength", "backlash", "tolerance", - translate( - "CycloidGear", + QT_TRANSLATE_NOOP( + "App::Property", "The arc length on the pitch circle by which the tooth thicknes is reduced.", ), ) @@ -147,8 +148,8 @@ def add_tolerance_properties(self, obj): "App::PropertyFloat", "head", "tolerance", - translate( - "CycloidGear", "head_value * module_value = additional length of head" + QT_TRANSLATE_NOOP( + "App::Property", "head_value * module_value = additional length of head" ), ) @@ -157,13 +158,17 @@ def add_cycloid_properties(self, obj): "App::PropertyFloat", "inner_diameter", "cycloid", - translate("CycloidGear", "inner_diameter divided by module (hypocycloid)"), + QT_TRANSLATE_NOOP( + "App::Property", "inner_diameter divided by module (hypocycloid)" + ), ) obj.addProperty( "App::PropertyFloat", "outer_diameter", "cycloid", - translate("CycloidGear", "outer_diameter divided by module (epicycloid)"), + QT_TRANSLATE_NOOP( + "App::Property", "outer_diameter divided by module (epicycloid)" + ), ) def add_computed_properties(self, obj): @@ -171,7 +176,7 @@ def add_computed_properties(self, obj): "App::PropertyLength", "dw", "computed", - translate("CycloidGear", "The pitch diameter."), + QT_TRANSLATE_NOOP("App::Property", "The pitch diameter."), ) obj.setExpression( "dw", "num_teeth * module" @@ -183,8 +188,8 @@ def add_computed_properties(self, obj): "App::PropertyAngle", "angular_backlash", "computed", - translate( - "CycloidGear", + QT_TRANSLATE_NOOP( + "App::Property", "The angle by which this gear can turn without moving the mating gear.", ), ) diff --git a/freecad/gears/cycloidgearrack.py b/freecad/gears/cycloidgearrack.py index 8f68f62..67b34c0 100644 --- a/freecad/gears/cycloidgearrack.py +++ b/freecad/gears/cycloidgearrack.py @@ -24,10 +24,11 @@ import numpy as np -from .translateutils import translate from pygears._functions import reflection from .basegear import BaseGear, fcvec, points_to_wire, insert_fillet +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class CycloidGearRack(BaseGear): """FreeCAD gear rack""" @@ -38,27 +39,27 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("CycloidGearRack", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("CycloidGearRack", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyLength", "thickness", "base", - translate("CycloidGearRack", "thickness"), + QT_TRANSLATE_NOOP("App::Property", "thickness"), ) obj.addProperty("App::PropertyLength", "module", "involute", "module") obj.addProperty( "App::PropertyBool", "simplified", "precision", - translate( - "CycloidGearRack", + QT_TRANSLATE_NOOP( + "App::Property", "if enabled the rack is drawn with a constant number of teeth to avoid topologic renaming.", ), ) @@ -66,13 +67,13 @@ def __init__(self, obj): "App::PropertyInteger", "numpoints", "accuracy", - translate("CycloidGearRack", "number of points for spline"), + QT_TRANSLATE_NOOP("App::Property", "number of points for spline"), ) obj.addProperty( "App::PropertyPythonObject", "rack", "base", - translate("CycloidGearRack", "test"), + QT_TRANSLATE_NOOP("App::Property", "test"), ) self.add_helical_properties(obj) @@ -100,13 +101,13 @@ def add_helical_properties(self, obj): "App::PropertyAngle", "beta", "helical", - translate("CycloidGearRack", "beta"), + QT_TRANSLATE_NOOP("App::Property", "beta"), ) obj.addProperty( "App::PropertyBool", "double_helix", "helical", - translate("CycloidGearRack", "double helix"), + QT_TRANSLATE_NOOP("App::Property", "double helix"), ) def add_computed_properties(self, obj): @@ -114,16 +115,16 @@ def add_computed_properties(self, obj): "App::PropertyLength", "transverse_pitch", "computed", - translate("CycloidGearRack", "pitch in the transverse plane"), + QT_TRANSLATE_NOOP("App::Property", "pitch in the transverse plane"), 1, ) obj.addProperty( "App::PropertyBool", "add_endings", "base", - translate( - "CycloidGearRack", - "if enabled the total length of the rack is num_teeth x pitch, otherwise the rack starts with a tooth-flank", + QT_TRANSLATE_NOOP( + "App::Property", + "if enabled the total length of the rack is teeth x pitch, otherwise the rack starts with a tooth-flank", ), ) @@ -132,14 +133,16 @@ def add_tolerance_properties(self, obj): "App::PropertyFloat", "head", "tolerance", - translate("CycloidGearRack", "head * module = additional length of head"), + QT_TRANSLATE_NOOP( + "App::Property", "head * module = additional length of head" + ), ) obj.addProperty( "App::PropertyFloat", "clearance", "tolerance", - translate( - "CycloidGearRack", "clearance * module = additional length of root" + QT_TRANSLATE_NOOP( + "App::Property", "clearance * module = additional length of root" ), ) @@ -148,16 +151,16 @@ def add_cycloid_properties(self, obj): "App::PropertyFloat", "inner_diameter", "cycloid", - translate( - "CycloidGearRack", "inner_diameter divided by module (hypocycloid)" + QT_TRANSLATE_NOOP( + "App::Property", "inner_diameter divided by module (hypocycloid)" ), ) obj.addProperty( "App::PropertyFloat", "outer_diameter", "cycloid", - translate( - "CycloidGearRack", "outer_diameter divided by module (epicycloid)" + QT_TRANSLATE_NOOP( + "App::Property", "outer_diameter divided by module (epicycloid)" ), ) @@ -166,8 +169,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "head_fillet", "fillets", - translate( - "CycloidGearRack", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), ) @@ -175,8 +178,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "root_fillet", "fillets", - translate( - "CycloidGearRack", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), ) diff --git a/freecad/gears/hypocycloidgear.py b/freecad/gears/hypocycloidgear.py index 1edfc39..999daa1 100644 --- a/freecad/gears/hypocycloidgear.py +++ b/freecad/gears/hypocycloidgear.py @@ -23,15 +23,15 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears.bevel_tooth import BevelTooth from pygears._functions import rotation from .basegear import BaseGear, make_bspline_wire +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP -class HypoCycloidGear(BaseGear): +class HypoCycloidGear(BaseGear): """parameters: pressure_angle: pressureangle, 10-30° pitch_angle: cone angle, 0 < pitch_angle < pi/4 @@ -43,91 +43,91 @@ def __init__(self, obj): "App::PropertyFloat", "pin_circle_radius", "gear_parameter", - translate( - "HypoCycloidGear", "Pin ball circle radius (overrides Tooth Pitch)" + QT_TRANSLATE_NOOP( + "App::Property", "Pin ball circle radius (overrides Tooth Pitch)" ), ) obj.addProperty( "App::PropertyFloat", "roller_diameter", "gear_parameter", - translate("HypoCycloidGear", "Roller Diameter"), + QT_TRANSLATE_NOOP("App::Property", "Roller Diameter"), ) obj.addProperty( "App::PropertyFloat", "eccentricity", "gear_parameter", - translate("HypoCycloidGear", "Eccentricity"), + QT_TRANSLATE_NOOP("App::Property", "Eccentricity"), ) obj.addProperty( "App::PropertyAngle", "pressure_angle_lim", "gear_parameter", - translate("HypoCycloidGear", "Pressure angle limit"), + QT_TRANSLATE_NOOP("App::Property", "Pressure angle limit"), ) obj.addProperty( "App::PropertyFloat", "pressure_angle_offset", "gear_parameter", - translate("HypoCycloidGear", "Offset in pressure angle"), + QT_TRANSLATE_NOOP("App::Property", "Offset in pressure angle"), ) obj.addProperty( "App::PropertyInteger", "teeth_number", "gear_parameter", - translate("HypoCycloidGear", "Number of teeth in Cam"), + QT_TRANSLATE_NOOP("App::Property", "Number of teeth in Cam"), ) obj.addProperty( "App::PropertyInteger", "segment_count", "gear_parameter", - translate( - "HypoCycloidGear", "Number of points used for spline interpolation" + QT_TRANSLATE_NOOP( + "App::Property", "Number of points used for spline interpolation" ), ) obj.addProperty( "App::PropertyLength", "hole_radius", "gear_parameter", - translate("HypoCycloidGear", "Center hole's radius"), + QT_TRANSLATE_NOOP("App::Property", "Center hole's radius"), ) obj.addProperty( "App::PropertyBool", "show_pins", "Pins", - translate("HypoCycloidGear", "Create pins in place"), + QT_TRANSLATE_NOOP("App::Property", "Create pins in place"), ) obj.addProperty( "App::PropertyLength", "pin_height", "Pins", - translate("HypoCycloidGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyBool", "center_pins", "Pins", - translate("HypoCycloidGear", "Center pin Z axis to generated disks"), + QT_TRANSLATE_NOOP("App::Property", "Center pin Z axis to generated disks"), ) obj.addProperty( "App::PropertyBool", "show_disk0", "Disks", - translate("HypoCycloidGear", "Show main cam disk"), + QT_TRANSLATE_NOOP("App::Property", "Show main cam disk"), ) obj.addProperty( "App::PropertyBool", "show_disk1", "Disks", - translate("HypoCycloidGear", "Show another reversed cam disk on top"), + QT_TRANSLATE_NOOP("App::Property", "Show another reversed cam disk on top"), ) obj.addProperty( "App::PropertyLength", "disk_height", "Disks", - translate("HypoCycloidGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.pin_circle_radius = 66 @@ -224,7 +224,7 @@ def generate_gear_shape(self, fp): # part.Wire(part.makeCircle(minRadius, app.Vector(-e, 0, 0))) # part.Wire(part.makeCircle(maxRadius, app.Vector(-e, 0, 0))) - app.Console.PrintMessage("Generating cam disk\r\n") + app.Console.PrintMessage(app.Qt.translate("Log", "Generating cam disk\n")) # generate the cam profile - note: shifted in -x by eccentricicy amount i = 0 x = self.calc_x(p, d, e, n, q * i / float(n)) @@ -264,7 +264,9 @@ def generate_gear_shape(self, fp): # secondary cam disk if fp.show_disk1: - app.Console.PrintMessage("Generating secondary cam disk\r\n") + app.Console.PrintMessage( + app.Qt.translate("Log", "Generating secondary cam disk\n") + ) second_cam = cam.copy() mat = app.Matrix() mat.rotateZ(np.pi) @@ -282,7 +284,7 @@ def generate_gear_shape(self, fp): # pins if fp.show_pins: - app.Console.PrintMessage("Generating pins\r\n") + app.Console.PrintMessage(app.Qt.translate("Log", "Generating pins\n")) pins = [] for i in range(0, n + 1): x = p * n * math.cos(2 * math.pi / (n + 1) * i) diff --git a/freecad/gears/init_gui.py b/freecad/gears/init_gui.py index 2030dff..c80dba6 100644 --- a/freecad/gears/init_gui.py +++ b/freecad/gears/init_gui.py @@ -23,6 +23,9 @@ __dirname__ = os.path.dirname(__file__) +# Add translations path +gui.addLanguagePath(os.path.join(__dirname__, "translations")) +gui.updateLocale() if sys.version_info[0] == 3 and sys.version_info[1] >= 11: # only works with 0.21.2 and above @@ -33,7 +36,7 @@ FC_COMMIT_REQUIRED = 33772 # Check FreeCAD version - app.Console.PrintLog("Checking FreeCAD version\n") + app.Console.PrintLog(app.Qt.translate("Log", "Checking FreeCAD version\n")) ver = app.Version() major_ver = int(ver[0]) minor_ver = int(ver[1]) @@ -64,7 +67,10 @@ ) ): app.Console.PrintWarning( - "FreeCAD version (currently {}.{}.{} ({})) must be at least {}.{}.{} ({}) in order to work with Python 3.11 and above\n".format( + app.Qt.translate( + "Log", + "FreeCAD version (currently {}.{}.{} ({})) must be at least {}.{}.{} ({}) in order to work with Python 3.11 and above\n", + ).format( int(ver[0]), minor_ver, patch_ver, @@ -80,8 +86,8 @@ class GearWorkbench(gui.Workbench): """A freecad workbench aiming at gear design""" - MenuText = "Gear" - ToolTip = "Gear Workbench" + MenuText = app.Qt.translate("Workbench", "Gear") + ToolTip = app.Qt.translate("Workbench", "Gear Workbench") Icon = os.path.join(__dirname__, "icons", "gearworkbench.svg") commands = [ "FCGear_InvoluteGear", @@ -103,10 +109,7 @@ def GetClassName(self): return "Gui::PythonWorkbench" def Initialize(self): - # Add translations path - gui.addLanguagePath(os.path.join(os.path.dirname(__file__), "translations")) - gui.updateLocale() - + QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP from .commands import ( CreateCycloidGear, CreateInvoluteGear, @@ -123,8 +126,8 @@ def Initialize(self): CreateGearConnector, ) - self.appendToolbar("Gear", self.commands) - self.appendMenu("Gear", self.commands) + self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Gear"), self.commands) + self.appendMenu(QT_TRANSLATE_NOOP("Workbench", "Gear"), self.commands) gui.addCommand("FCGear_InvoluteGear", CreateInvoluteGear()) gui.addCommand("FCGear_InternalInvoluteGear", CreateInternalInvoluteGear()) gui.addCommand("FCGear_CycloidGear", CreateCycloidGear()) diff --git a/freecad/gears/internalinvolutegear.py b/freecad/gears/internalinvolutegear.py index 44ec10a..afcffcc 100644 --- a/freecad/gears/internalinvolutegear.py +++ b/freecad/gears/internalinvolutegear.py @@ -21,10 +21,12 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears.involute_tooth import InvoluteTooth from pygears._functions import rotation +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + + from .basegear import ( BaseGear, points_to_wire, @@ -48,20 +50,20 @@ def __init__(self, obj): "App::PropertyBool", "simple", "precision", - translate("InternalInvoluteGear", "simple"), + QT_TRANSLATE_NOOP("App::Property", "simple"), ) obj.addProperty( "App::PropertyInteger", "num_teeth", "base", - translate("InternalInvoluteGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate( - "InternalInvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "normal module if properties_from_tool=True, else it's the transverse module.", ), ) @@ -69,25 +71,25 @@ def __init__(self, obj): "App::PropertyLength", "height", "base", - translate("InternalInvoluteGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyLength", "thickness", "base", - translate("InternalInvoluteGear", "thickness"), + QT_TRANSLATE_NOOP("App::Property", "thickness"), ) obj.addProperty( "App::PropertyInteger", "numpoints", "accuracy", - translate("InternalInvoluteGear", "number of points for spline"), + QT_TRANSLATE_NOOP("App::Property", "number of points for spline"), ) obj.addProperty( "App::PropertyPythonObject", "gear", "base", - translate("InternalInvoluteGear", "test"), + QT_TRANSLATE_NOOP("App::Property", "test"), ) self.add_involute_properties(obj) @@ -123,14 +125,14 @@ def add_limiting_diameter_properties(self, obj): "App::PropertyLength", "da", "computed", - translate("InternalInvoluteGear", "inside diameter"), + QT_TRANSLATE_NOOP("App::Property", "inside diameter"), 1, ) obj.addProperty( "App::PropertyLength", "df", "computed", - translate("InternalInvoluteGear", "root diameter"), + QT_TRANSLATE_NOOP("App::Property", "root diameter"), 1, ) @@ -139,14 +141,14 @@ def add_computed_properties(self, obj): "App::PropertyLength", "dw", "computed", - translate("InternalInvoluteGear", "The pitch diameter."), + QT_TRANSLATE_NOOP("App::Property", "The pitch diameter."), ) obj.addProperty( "App::PropertyAngle", "angular_backlash", "computed", - translate( - "InternalInvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "The angle by which this gear can turn without moving the mating gear.", ), ) @@ -160,14 +162,14 @@ def add_computed_properties(self, obj): "App::PropertyLength", "transverse_pitch", "computed", - translate("InternalInvoluteGear", "transverse_pitch"), + QT_TRANSLATE_NOOP("App::Property", "transverse_pitch"), 1, ) obj.addProperty( "App::PropertyLength", "outside_diameter", "computed", - translate("InternalInvoluteGear", "Outside diameter"), + QT_TRANSLATE_NOOP("App::Property", "Outside diameter"), 1, ) @@ -176,8 +178,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "head_fillet", "fillets", - translate( - "InternalInvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), ) @@ -185,8 +187,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "root_fillet", "fillets", - translate( - "InternalInvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), ) @@ -196,8 +198,8 @@ def add_tolerance_properties(self, obj): "App::PropertyLength", "backlash", "tolerance", - translate( - "InternalInvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "The arc length on the pitch circle by which the tooth thicknes is reduced.", ), ) @@ -205,14 +207,14 @@ def add_tolerance_properties(self, obj): "App::PropertyBool", "reversed_backlash", "tolerance", - translate("InternalInvoluteGear", "backlash direction"), + QT_TRANSLATE_NOOP("App::Property", "backlash direction"), ) obj.addProperty( "App::PropertyFloat", "head", "tolerance", - translate( - "InternalInvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "head_value * module_value = additional length of head", ), ) @@ -220,7 +222,7 @@ def add_tolerance_properties(self, obj): "App::PropertyFloat", "clearance", "tolerance", - translate("InternalInvoluteGear", "clearance"), + QT_TRANSLATE_NOOP("App::Property", "clearance"), ) def add_involute_properties(self, obj): @@ -228,13 +230,13 @@ def add_involute_properties(self, obj): "App::PropertyFloat", "shift", "involute", - translate("InternalInvoluteGear", "shift"), + QT_TRANSLATE_NOOP("App::Property", "shift"), ) obj.addProperty( "App::PropertyAngle", "pressure_angle", "involute", - translate("InternalInvoluteGear", "pressure angle"), + QT_TRANSLATE_NOOP("App::Property", "pressure angle"), ) def add_helical_properties(self, obj): @@ -242,20 +244,20 @@ def add_helical_properties(self, obj): "App::PropertyAngle", "beta", "helical", - translate("InternalInvoluteGear", "beta"), + QT_TRANSLATE_NOOP("App::Property", "beta"), ) obj.addProperty( "App::PropertyBool", "double_helix", "helical", - translate("InternalInvoluteGear", "double helix"), + QT_TRANSLATE_NOOP("App::Property", "double helix"), ) obj.addProperty( "App::PropertyBool", "properties_from_tool", "helical", - translate( - "InternalInvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "if beta is given and properties_from_tool is enabled, gear parameters are internally recomputed for the rotated gear", ), ) diff --git a/freecad/gears/involutegear.py b/freecad/gears/involutegear.py index 4c5ac49..9948163 100644 --- a/freecad/gears/involutegear.py +++ b/freecad/gears/involutegear.py @@ -21,11 +21,11 @@ from freecad import app from freecad import part -from .translateutils import translate - from pygears.involute_tooth import InvoluteTooth from pygears._functions import rotation +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + from .basegear import ( BaseGear, points_to_wire, @@ -46,7 +46,7 @@ def __init__(self, obj): "App::PropertyPythonObject", "gear", "base", - translate("InvoluteGear", "python gear object"), + QT_TRANSLATE_NOOP("App::Property", "python gear object"), ) self.add_gear_properties(obj) @@ -83,14 +83,14 @@ def add_gear_properties(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("InvoluteGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate( - "InvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "normal module if properties_from_tool=True, else it's the transverse module.", ), ) @@ -98,19 +98,19 @@ def add_gear_properties(self, obj): "App::PropertyLength", "height", "base", - translate("InvoluteGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyAngle", "pressure_angle", "involute", - translate("InvoluteGear", "pressure angle"), + QT_TRANSLATE_NOOP("App::Property", "pressure angle"), ) obj.addProperty( "App::PropertyFloat", "shift", "involute", - translate("InvoluteGear", "shift"), + QT_TRANSLATE_NOOP("App::Property", "shift"), ) def add_fillet_properties(self, obj): @@ -118,14 +118,14 @@ def add_fillet_properties(self, obj): "App::PropertyBool", "undercut", "fillets", - translate("InvoluteGear", "undercut"), + QT_TRANSLATE_NOOP("App::Property", "undercut"), ) obj.addProperty( "App::PropertyFloat", "head_fillet", "fillets", - translate( - "InvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), ) @@ -133,8 +133,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "root_fillet", "fillets", - translate( - "InvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), ) @@ -144,8 +144,8 @@ def add_helical_properties(self, obj): "App::PropertyBool", "properties_from_tool", "helical", - translate( - "InvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "if beta is given and properties_from_tool is enabled, gear parameters are internally recomputed for the rotated gear", ), ) @@ -153,13 +153,13 @@ def add_helical_properties(self, obj): "App::PropertyAngle", "beta", "helical", - translate("InvoluteGear", "beta"), + QT_TRANSLATE_NOOP("App::Property", "beta"), ) obj.addProperty( "App::PropertyBool", "double_helix", "helical", - translate("InvoluteGear", "double helix"), + QT_TRANSLATE_NOOP("App::Property", "double helix"), ) def add_computed_properties(self, obj): @@ -167,14 +167,14 @@ def add_computed_properties(self, obj): "App::PropertyLength", "da", "computed", - translate("InvoluteGear", "outside diameter"), + QT_TRANSLATE_NOOP("App::Property", "outside diameter"), 1, ) obj.addProperty( "App::PropertyLength", "df", "computed", - translate("InvoluteGear", "root diameter"), + QT_TRANSLATE_NOOP("App::Property", "root diameter"), 1, ) self.add_traverse_module_property(obj) @@ -182,15 +182,15 @@ def add_computed_properties(self, obj): "App::PropertyLength", "dw", "computed", - translate("InvoluteGear", "The pitch diameter."), + QT_TRANSLATE_NOOP("App::Property", "The pitch diameter."), 1, ) obj.addProperty( "App::PropertyAngle", "angular_backlash", "computed", - translate( - "InvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "The angle by which this gear can turn without moving the mating gear.", ), ) @@ -204,7 +204,7 @@ def add_computed_properties(self, obj): "App::PropertyLength", "transverse_pitch", "computed", - translate("InvoluteGear", "transverse_pitch"), + QT_TRANSLATE_NOOP("App::Property", "transverse_pitch"), 1, ) @@ -213,8 +213,8 @@ def add_tolerance_properties(self, obj): "App::PropertyLength", "backlash", "tolerance", - translate( - "InvoluteGear", + QT_TRANSLATE_NOOP( + "App::Property", "The arc length on the pitch circle by which the tooth thicknes is reduced.", ), ) @@ -222,20 +222,20 @@ def add_tolerance_properties(self, obj): "App::PropertyBool", "reversed_backlash", "tolerance", - translate("InvoluteGear", "backlash direction"), + QT_TRANSLATE_NOOP("App::Property", "backlash direction"), ) obj.addProperty( "App::PropertyFloat", "clearance", "tolerance", - translate("InvoluteGear", "clearance"), + QT_TRANSLATE_NOOP("App::Property", "clearance"), ) obj.addProperty( "App::PropertyFloat", "head", "tolerance", - translate( - "InvoluteGear", "head_value * module_value = additional length of head" + QT_TRANSLATE_NOOP( + "App::Property", "head_value * module_value = additional length of head" ), ) @@ -244,13 +244,13 @@ def add_accuracy_properties(self, obj): "App::PropertyBool", "simple", "accuracy", - translate("InvoluteGear", "simple"), + QT_TRANSLATE_NOOP("App::Property", "simple"), ) obj.addProperty( "App::PropertyInteger", "numpoints", "accuracy", - translate("InvoluteGear", "number of points for spline"), + QT_TRANSLATE_NOOP("App::Property", "number of points for spline"), ) def add_traverse_module_property(self, obj): @@ -258,7 +258,7 @@ def add_traverse_module_property(self, obj): "App::PropertyLength", "traverse_module", "computed", - translate("InvoluteGear", "traverse module of the generated gear"), + QT_TRANSLATE_NOOP("App::Property", "traverse module of the generated gear"), 1, ) diff --git a/freecad/gears/involutegearrack.py b/freecad/gears/involutegearrack.py index b831a73..18f5f65 100644 --- a/freecad/gears/involutegearrack.py +++ b/freecad/gears/involutegearrack.py @@ -21,10 +21,11 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears.involute_tooth import InvoluteRack from .basegear import BaseGear, fcvec, points_to_wire, insert_fillet +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class InvoluteGearRack(BaseGear): """FreeCAD gear rack""" @@ -36,32 +37,32 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("InvoluteGearRack", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("InvoluteGearRack", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate("InvoluteGearRack", "module"), + QT_TRANSLATE_NOOP("App::Property", "module"), ) obj.addProperty( "App::PropertyLength", "thickness", "base", - translate("InvoluteGearRack", "thickness"), + QT_TRANSLATE_NOOP("App::Property", "thickness"), ) obj.addProperty( "App::PropertyBool", "simplified", "precision", - translate( - "InvoluteGearRack", + QT_TRANSLATE_NOOP( + "App::Property", "if enabled the rack is drawn with a constant number of teeth to avoid topologic renaming.", ), ) @@ -69,7 +70,7 @@ def __init__(self, obj): "App::PropertyPythonObject", "rack", "base", - translate("InvoluteGearRack", "test"), + QT_TRANSLATE_NOOP("App::Property", "test"), ) self.add_helical_properties(obj) @@ -97,8 +98,8 @@ def add_helical_properties(self, obj): "App::PropertyBool", "properties_from_tool", "helical", - translate( - "InvoluteGearRack", + QT_TRANSLATE_NOOP( + "App::Property", "if beta is given and properties_from_tool is enabled, gear parameters are internally recomputed for the rotated gear", ), ) @@ -106,13 +107,13 @@ def add_helical_properties(self, obj): "App::PropertyAngle", "beta", "helical", - translate("InvoluteGearRack", "beta"), + QT_TRANSLATE_NOOP("App::Property", "beta"), ) obj.addProperty( "App::PropertyBool", "double_helix", "helical", - translate("InvoluteGearRack", "double helix"), + QT_TRANSLATE_NOOP("App::Property", "double helix"), ) def add_computed_properties(self, obj): @@ -120,16 +121,16 @@ def add_computed_properties(self, obj): "App::PropertyLength", "transverse_pitch", "computed", - translate("InvoluteGearRack", "pitch in the transverse plane"), + QT_TRANSLATE_NOOP("App::Property", "pitch in the transverse plane"), 1, ) obj.addProperty( "App::PropertyBool", "add_endings", "base", - translate( - "InvoluteGearRack", - "if enabled the total length of the rack is num_teeth x pitch, otherwise the rack starts with a tooth-flank", + QT_TRANSLATE_NOOP( + "App::Property", + "if enabled the total length of the rack is teeth x pitch, otherwise the rack starts with a tooth-flank", ), ) @@ -138,14 +139,16 @@ def add_tolerance_properties(self, obj): "App::PropertyFloat", "head", "tolerance", - translate("InvoluteGearRack", "head * module = additional length of head"), + QT_TRANSLATE_NOOP( + "App::Property", "head * module = additional length of head" + ), ) obj.addProperty( "App::PropertyFloat", "clearance", "tolerance", - translate( - "InvoluteGearRack", "clearance * module = additional length of root" + QT_TRANSLATE_NOOP( + "App::Property", "clearance * module = additional length of root" ), ) @@ -154,7 +157,7 @@ def add_involute_properties(self, obj): "App::PropertyAngle", "pressure_angle", "involute", - translate("InvoluteGearRack", "pressure angle"), + QT_TRANSLATE_NOOP("App::Property", "pressure angle"), ) def add_fillet_properties(self, obj): @@ -162,8 +165,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "head_fillet", "fillets", - translate( - "InvoluteGearRack", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), ) @@ -171,8 +174,8 @@ def add_fillet_properties(self, obj): "App::PropertyFloat", "root_fillet", "fillets", - translate( - "InvoluteGearRack", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), ) diff --git a/freecad/gears/lanterngear.py b/freecad/gears/lanterngear.py index 9ddc66c..b15baa2 100644 --- a/freecad/gears/lanterngear.py +++ b/freecad/gears/lanterngear.py @@ -22,12 +22,13 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears.bevel_tooth import BevelTooth from pygears._functions import rotation from .basegear import BaseGear, fcvec, part_arc_from_points_and_center +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class LanternGear(BaseGear): def __init__(self, obj): @@ -36,37 +37,39 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "gear_parameter", - translate("LanternGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate("LanternGear", "module"), + QT_TRANSLATE_NOOP("App::Property", "module"), ) obj.addProperty( "App::PropertyLength", "bolt_radius", "base", - translate("LanternGear", "the bolt radius of the rack/chain"), + QT_TRANSLATE_NOOP("App::Property", "the bolt radius of the rack/chain"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("LanternGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyInteger", "num_profiles", "accuracy", - translate("LanternGear", "number of profiles used for loft"), + QT_TRANSLATE_NOOP("App::Property", "number of profiles used for loft"), ) obj.addProperty( "App::PropertyFloat", "head", "tolerance", - translate("LanternGear", "head * module = additional length of head"), + QT_TRANSLATE_NOOP( + "App::Property", "head * module = additional length of head" + ), ) obj.num_teeth = 15 diff --git a/freecad/gears/timinggear.py b/freecad/gears/timinggear.py index f31b4bc..259527e 100644 --- a/freecad/gears/timinggear.py +++ b/freecad/gears/timinggear.py @@ -21,10 +21,11 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears._functions import reflection from .basegear import BaseGear, part_arc_from_points_and_center +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class TimingGear(BaseGear): """FreeCAD gear rack""" @@ -108,40 +109,40 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("TimingGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyEnumeration", "type", "base", - translate("TimingGear", "type of timing-gear"), + QT_TRANSLATE_NOOP("App::Property", "type of timing-gear"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("TimingGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyLength", "pitch", "computed", - translate("TimingGear", "pitch of gear"), + QT_TRANSLATE_NOOP("App::Property", "pitch of gear"), 1, ) obj.addProperty( "App::PropertyLength", "h", "computed", - translate("TimingGear", "radial height of teeth"), + QT_TRANSLATE_NOOP("App::Property", "radial height of teeth"), 1, ) obj.addProperty( "App::PropertyLength", "u", "computed", - translate( - "TimingGear", + QT_TRANSLATE_NOOP( + "App::Property", "radial difference between pitch diameter and head of gear", ), 1, @@ -150,28 +151,28 @@ def __init__(self, obj): "App::PropertyLength", "r0", "computed", - translate("TimingGear", "radius of first arc"), + QT_TRANSLATE_NOOP("App::Property", "radius of first arc"), 1, ) obj.addProperty( "App::PropertyLength", "r1", "computed", - translate("TimingGear", "radius of second arc"), + QT_TRANSLATE_NOOP("App::Property", "radius of second arc"), 1, ) obj.addProperty( "App::PropertyLength", "rs", "computed", - translate("TimingGear", "radius of third arc"), + QT_TRANSLATE_NOOP("App::Property", "radius of third arc"), 1, ) obj.addProperty( "App::PropertyLength", "offset", "computed", - translate("TimingGear", "x-offset of second arc-midpoint"), + QT_TRANSLATE_NOOP("App::Property", "x-offset of second arc-midpoint"), 1, ) obj.num_teeth = 15 diff --git a/freecad/gears/timinggear_t.py b/freecad/gears/timinggear_t.py index 382e92c..4f4ddbe 100644 --- a/freecad/gears/timinggear_t.py +++ b/freecad/gears/timinggear_t.py @@ -24,11 +24,12 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears._functions import rotation, reflection from .basegear import BaseGear, fcvec, part_arc_from_points_and_center, insert_fillet +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class TimingGearT(BaseGear): def __init__(self, obj): @@ -36,32 +37,34 @@ def __init__(self, obj): "App::PropertyLength", "pitch", "base", - translate("TimingGearT", "pitch of gear"), + QT_TRANSLATE_NOOP("App::Property", "pitch of gear"), ) obj.addProperty( "App::PropertyInteger", "num_teeth", "base", - translate("TimingGearT", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "tooth_height", "base", - translate("TimingGearT", "radial height of tooth"), + QT_TRANSLATE_NOOP("App::Property", "radial height of tooth"), ) obj.addProperty( "App::PropertyLength", "u", "base", - translate("TimingGearT", "radial distance from tooth-head to pitch circle"), + QT_TRANSLATE_NOOP( + "App::Property", "radial distance from tooth-head to pitch circle" + ), ) obj.addProperty( "App::PropertyLength", "backlash", "tolerance", - translate( - "TimingGearT", + QT_TRANSLATE_NOOP( + "App::Property", "The arc length on the pitch circle by which the tooth thicknes is reduced.", ), ) @@ -69,8 +72,8 @@ def __init__(self, obj): "App::PropertyFloat", "head_fillet", "fillets", - translate( - "TimingGearT", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-head, radius = head_fillet x module", ), ) @@ -78,8 +81,8 @@ def __init__(self, obj): "App::PropertyFloat", "root_fillet", "fillets", - translate( - "TimingGearT", + QT_TRANSLATE_NOOP( + "App::Property", "a fillet for the tooth-root, radius = root_fillet x module", ), ) @@ -87,13 +90,13 @@ def __init__(self, obj): "App::PropertyAngle", "alpha", "base", - translate("TimingGearT", "angle of tooth flanks"), + QT_TRANSLATE_NOOP("App::Property", "angle of tooth flanks"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("TimingGearT", "extrusion height"), + QT_TRANSLATE_NOOP("App::Property", "extrusion height"), ) obj.pitch = "5. mm" obj.num_teeth = 15 diff --git a/freecad/gears/translateutils.py b/freecad/gears/translateutils.py deleted file mode 100644 index 116c235..0000000 --- a/freecad/gears/translateutils.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf8 -*- - -# *************************************************************************** -# * * -# * Copyright (c) 2020 kbwbe * -# * * -# * * -# * This program is free software; you can redistribute it and/or modify * -# * it under the terms of the GNU Lesser General Public License (LGPL) * -# * as published by the Free Software Foundation; either version 2 of * -# * the License, or (at your option) any later version. * -# * for detail see the LICENCE text file. * -# * * -# * This program is distributed in the hope that it will be useful, * -# * but WITHOUT ANY WARRANTY; without even the implied warranty of * -# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -# * GNU Library General Public License for more details. * -# * * -# * You should have received a copy of the GNU Library General Public * -# * License along with this program; if not, write to the Free Software * -# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -# * USA * -# * * -# *************************************************************************** - -import FreeCAD - - -if FreeCAD.GuiUp: - from PySide.QtCore import QT_TRANSLATE_NOOP - from DraftGui import translate -else: - - def QT_TRANSLATE_NOOP(context, text): - return text - - def translate(context, text): - return text diff --git a/freecad/gears/wormgear.py b/freecad/gears/wormgear.py index c851919..a6f59ef 100644 --- a/freecad/gears/wormgear.py +++ b/freecad/gears/wormgear.py @@ -21,12 +21,13 @@ from freecad import app from freecad import part -from .translateutils import translate from pygears.involute_tooth import InvoluteTooth from pygears._functions import rotation from .basegear import BaseGear, helical_extrusion, fcvec +QT_TRANSLATE_NOOP = app.Qt.QT_TRANSLATE_NOOP + class WormGear(BaseGear): """FreeCAD gear rack""" @@ -37,56 +38,60 @@ def __init__(self, obj): "App::PropertyInteger", "num_teeth", "base", - translate("WormGear", "number of teeth"), + QT_TRANSLATE_NOOP("App::Property", "number of teeth"), ) obj.addProperty( "App::PropertyLength", "module", "base", - translate("WormGear", "module"), + QT_TRANSLATE_NOOP("App::Property", "module"), ) obj.addProperty( "App::PropertyLength", "height", "base", - translate("WormGear", "height"), + QT_TRANSLATE_NOOP("App::Property", "height"), ) obj.addProperty( "App::PropertyLength", "diameter", "base", - translate("WormGear", "diameter"), + QT_TRANSLATE_NOOP("App::Property", "diameter"), ) obj.addProperty( "App::PropertyAngle", "beta", "computed", - translate("WormGear", "beta"), + QT_TRANSLATE_NOOP("App::Property", "beta"), 1, ) obj.addProperty( "App::PropertyAngle", "pressure_angle", "involute", - translate("WormGear", "pressure angle"), + QT_TRANSLATE_NOOP("App::Property", "pressure angle"), ) obj.addProperty( "App::PropertyBool", "reverse_pitch", "base", - translate("WormGear", "reverse rotation of helix"), + QT_TRANSLATE_NOOP("App::Property", "reverse rotation of helix"), ) obj.addProperty( "App::PropertyFloat", "head", "tolerance", - translate("WormGear", "head * module = additional length of head"), + QT_TRANSLATE_NOOP( + "App::Property", "head * module = additional length of head" + ), ) obj.addProperty( "App::PropertyFloat", "clearance", "tolerance", - translate("WormGear", "clearance * module = additional length of root"), + QT_TRANSLATE_NOOP( + "App::Property", "clearance * module = additional length of root" + ), ) obj.num_teeth = 3 obj.module = "1. mm"