From 94426e1f541bdadbc336925e0bb10b2d9b42f4ec Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sat, 12 Aug 2023 16:25:34 -0700 Subject: [PATCH] TD: Translate default labels --- src/Mod/TechDraw/Gui/TaskActiveView.cpp | 7 ++++++- src/Mod/TechDraw/Gui/TaskComplexSection.cpp | 7 ++++++- src/Mod/TechDraw/Gui/TaskDetail.cpp | 7 ++++++- src/Mod/TechDraw/Gui/TaskHatch.cpp | 7 +++++-- src/Mod/TechDraw/Gui/TaskLeaderLine.cpp | 7 ++++++- src/Mod/TechDraw/Gui/TaskRichAnno.cpp | 7 ++++++- src/Mod/TechDraw/Gui/TaskSectionView.cpp | 7 ++++++- src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp | 8 +++++++- 8 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.cpp b/src/Mod/TechDraw/Gui/TaskActiveView.cpp index e63c8b430f..7239f594e2 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.cpp +++ b/src/Mod/TechDraw/Gui/TaskActiveView.cpp @@ -135,7 +135,9 @@ TechDraw::DrawViewImage* TaskActiveView::createActiveView() } //we are sure we have a 3D window! - std::string imageName = m_pageFeat->getDocument()->getUniqueObjectName("ActiveView"); + const std::string objectName{QT_TR_NOOP("ActiveView")}; + std::string imageName = m_pageFeat->getDocument()->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {imageName.substr(objectName.length())}; std::string imageType = "TechDraw::DrawViewImage"; std::string pageName = m_pageFeat->getNameInDocument(); @@ -210,6 +212,9 @@ TechDraw::DrawViewImage* TaskActiveView::createActiveView() } } + std::string translatedObjectName{tr("ActiveView").toStdString()}; + newObj->Label.setValue(translatedObjectName + generatedSuffix); + return newImg; } diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp index 3ff4541fb6..38aa958fc7 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp @@ -556,7 +556,9 @@ void TaskComplexSection::createComplexSection() Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create ComplexSection")); if (!m_section) { - m_sectionName = m_page->getDocument()->getUniqueObjectName("ComplexSection"); + const std::string objectName{QT_TR_NOOP("ComplexSection")}; + std::string imageName = m_page->getDocument()->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {imageName.substr(objectName.length())}; std::string sectionType = "TechDraw::DrawComplexSection"; Command::doCommand(Command::Doc, "App.ActiveDocument.addObject('%s', '%s')", @@ -625,6 +627,9 @@ void TaskComplexSection::createComplexSection() double rotation = requiredRotation(viewDirectionAngle); Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Rotation = %.6f", m_sectionName.c_str(), rotation); + + std::string translatedObjectName{tr(objectName.c_str()).toStdString()}; + newObj->Label.setValue(translatedObjectName + generatedSuffix); } Gui::Command::commitCommand(); } diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index 099b89f8cc..75a51ef543 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -434,7 +434,9 @@ void TaskDetail::createDetail() // Base::Console().Message("TD::createDetail()\n"); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Detail View")); - m_detailName = m_doc->getUniqueObjectName("Detail"); + const std::string objectName{QT_TR_NOOP("Detail")}; + std::string m_detailName = m_doc->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {m_detailName.substr(objectName.length())}; Gui::Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawViewDetail', '%s')", m_detailName.c_str()); @@ -458,6 +460,9 @@ void TaskDetail::createDetail() Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", m_pageName.c_str(), m_detailName.c_str()); + std::string translatedObjectName{tr(objectName.c_str()).toStdString()}; + docObj->Label.setValue(translatedObjectName + generatedSuffix); + Gui::Command::updateActive(); Gui::Command::commitCommand(); diff --git a/src/Mod/TechDraw/Gui/TaskHatch.cpp b/src/Mod/TechDraw/Gui/TaskHatch.cpp index be995518ef..d72b47f2df 100644 --- a/src/Mod/TechDraw/Gui/TaskHatch.cpp +++ b/src/Mod/TechDraw/Gui/TaskHatch.cpp @@ -195,9 +195,12 @@ void TaskHatch::createHatch() { // Base::Console().Message("TH::createHatch()\n"); App::Document* doc = m_dvp->getDocument(); - std::string FeatName = doc->getUniqueObjectName("Hatch"); + const std::string objectName{QT_TR_NOOP("Hatch")}; + std::string FeatName = doc->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {FeatName.substr(objectName.length())}; + std::string translatedObjectName{tr(objectName.c_str()).toStdString()}; std::stringstream featLabel; - featLabel << FeatName << "F" << + featLabel << translatedObjectName << generatedSuffix << "F" << TechDraw::DrawUtil::getIndexFromName(m_subs.at(0)); //use 1st face# for label Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Hatch")); diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp index 34b9fce81a..a0baaece75 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp @@ -335,7 +335,9 @@ void TaskLeaderLine::onLineStyleChanged() void TaskLeaderLine::createLeaderFeature(std::vector converted) { // Base::Console().Message("TTL::createLeaderFeature()\n"); - m_leaderName = m_basePage->getDocument()->getUniqueObjectName("LeaderLine"); + const std::string objectName{QT_TR_NOOP("LeaderLine")}; + std::string m_leaderName = m_basePage->getDocument()->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {m_leaderName.substr(objectName.length())}; m_leaderType = "TechDraw::DrawLeaderLine"; std::string PageName = m_basePage->getNameInDocument(); @@ -377,6 +379,9 @@ void TaskLeaderLine::createLeaderFeature(std::vector converted) } } + std::string translatedObjectName{tr(objectName.c_str()).toStdString()}; + obj->Label.setValue(translatedObjectName + generatedSuffix); + Gui::Command::updateActive(); Gui::Command::commitCommand(); diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp index c2f121cfe2..d1f5d752d7 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp @@ -280,7 +280,9 @@ App::Color TaskRichAnno::prefLineColor() void TaskRichAnno::createAnnoFeature() { // Base::Console().Message("TRA::createAnnoFeature()"); - std::string annoName = m_basePage->getDocument()->getUniqueObjectName("RichTextAnnotation"); + const std::string objectName{QT_TR_NOOP("RichTextAnnotation")}; + std::string annoName = m_basePage->getDocument()->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {annoName.substr(objectName.length())}; std::string annoType = "TechDraw::DrawRichAnno"; std::string PageName = m_basePage->getNameInDocument(); @@ -326,6 +328,9 @@ void TaskRichAnno::createAnnoFeature() } } + std::string translatedObjectName{tr(objectName.c_str()).toStdString()}; + obj->Label.setValue(translatedObjectName + generatedSuffix); + Gui::Command::commitCommand(); Gui::Command::updateActive(); diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index f6d2a0b93d..5b52e59c92 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -500,7 +500,9 @@ TechDraw::DrawViewSection* TaskSectionView::createSectionView(void) Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create SectionView")); if (!m_section) { - m_sectionName = m_base->getDocument()->getUniqueObjectName("SectionView"); + const std::string objectName{QT_TR_NOOP("SectionView")}; + std::string m_sectionName = m_base->getDocument()->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {m_sectionName.substr(objectName.length())}; std::string sectionType = "TechDraw::DrawViewSection"; Command::doCommand(Command::Doc, "App.ActiveDocument.addObject('%s', '%s')", @@ -545,6 +547,9 @@ TechDraw::DrawViewSection* TaskSectionView::createSectionView(void) double rotation = requiredRotation(viewDirectionAngle); Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Rotation = %.6f", m_sectionName.c_str(), rotation); + + std::string translatedObjectName{tr(objectName.c_str()).toStdString()}; + newObj->Label.setValue(translatedObjectName + generatedSuffix); } Gui::Command::commitCommand(); return m_section; diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp index 31ec9803aa..8e99d56215 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp @@ -457,7 +457,10 @@ TechDraw::DrawWeldSymbol* TaskWeldingSymbol::createWeldingSymbol() { // Base::Console().Message("TWS::createWeldingSymbol()\n"); - std::string symbolName = m_leadFeat->getDocument()->getUniqueObjectName("WeldSymbol"); + const std::string objectName{QT_TR_NOOP("SectionView")}; + std::string symbolName = m_leadFeat->getDocument()->getUniqueObjectName(objectName.c_str()); + std::string generatedSuffix {symbolName.substr(objectName.length())}; + std::string symbolType = "TechDraw::DrawWeldSymbol"; TechDraw::DrawPage* page = m_leadFeat->findParentPage(); @@ -495,6 +498,9 @@ TechDraw::DrawWeldSymbol* TaskWeldingSymbol::createWeldingSymbol() if (!newObj || !newSym) throw Base::RuntimeError("TaskWeldingSymbol - new symbol object not found"); + std::string translatedObjectName{tr(objectName.c_str()).toStdString()}; + newObj->Label.setValue(translatedObjectName + generatedSuffix); + return newSym; }