From 726e786493cfdd4481608232a683ff98ac18effc Mon Sep 17 00:00:00 2001 From: Ronny Standtke Date: Tue, 18 Apr 2023 12:23:37 +0200 Subject: [PATCH 1/2] added i18n for new body labels --- src/Mod/PartDesign/Gui/CommandBody.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index 3be347b2c3..02db8ae789 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -189,9 +189,13 @@ void CmdPartDesignBody::activated(int iMsg) openCommand(QT_TRANSLATE_NOOP("Command", "Add a Body")); std::string bodyName = getUniqueObjectName("Body"); + const char* bodyString = bodyName.c_str(); // add the Body feature itself, and make it active - doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')", bodyName.c_str()); + doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')", bodyString); + // set Label for i18n/L10N + QByteArray labelByteArray = QObject::tr("Body").toUtf8(); + doCommand(Doc,"App.ActiveDocument.getObject('%s').Label = '%s'", bodyString, labelByteArray.constData()); if (baseFeature) { if (partOfBaseFeature){ //withdraw base feature from Part, otherwise visibility mandess results @@ -200,30 +204,30 @@ void CmdPartDesignBody::activated(int iMsg) } if (addtogroup) { doCommand(Doc,"App.activeDocument().%s.Group = [App.activeDocument().%s]", - bodyName.c_str(), baseFeature->getNameInDocument()); + bodyString, baseFeature->getNameInDocument()); } else { doCommand(Doc,"App.activeDocument().%s.BaseFeature = App.activeDocument().%s", - bodyName.c_str(), baseFeature->getNameInDocument()); + bodyString, baseFeature->getNameInDocument()); } } addModule(Gui,"PartDesignGui"); // import the Gui module only once a session doCommand(Gui::Command::Gui, "Gui.activateView('Gui::View3DInventor', True)\n" "Gui.activeView().setActiveObject('%s', App.activeDocument().%s)", - PDBODYKEY, bodyName.c_str()); + PDBODYKEY, bodyString); // Make the "Create sketch" prompt appear in the task panel doCommand(Gui,"Gui.Selection.clearSelection()"); - doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", bodyName.c_str()); + doCommand(Gui,"Gui.Selection.addSelection(App.ActiveDocument.%s)", bodyString); if (actPart) { doCommand(Doc,"App.activeDocument().%s.addObject(App.ActiveDocument.%s)", - actPart->getNameInDocument(), bodyName.c_str()); + actPart->getNameInDocument(), bodyString); } // check if a proxy object has been created for the base feature inside the body if (baseFeature) { PartDesign::Body* body = dynamic_cast - (baseFeature->getDocument()->getObject(bodyName.c_str())); + (baseFeature->getDocument()->getObject(bodyString)); if (body) { std::vector links = body->Group.getValues(); for (auto it : links) { From ff324c9df78b3f08f8318ad62bf7f24cab8c91f4 Mon Sep 17 00:00:00 2001 From: Ronny Standtke Date: Tue, 18 Apr 2023 12:24:21 +0200 Subject: [PATCH 2/2] fixed typo --- src/Mod/PartDesign/Gui/CommandBody.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/Gui/CommandBody.cpp b/src/Mod/PartDesign/Gui/CommandBody.cpp index 02db8ae789..65014d6960 100644 --- a/src/Mod/PartDesign/Gui/CommandBody.cpp +++ b/src/Mod/PartDesign/Gui/CommandBody.cpp @@ -198,7 +198,7 @@ void CmdPartDesignBody::activated(int iMsg) doCommand(Doc,"App.ActiveDocument.getObject('%s').Label = '%s'", bodyString, labelByteArray.constData()); if (baseFeature) { if (partOfBaseFeature){ - //withdraw base feature from Part, otherwise visibility mandess results + //withdraw base feature from Part, otherwise visibility madness results doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)", partOfBaseFeature->getNameInDocument(), baseFeature->getNameInDocument()); }