diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 084388fbe9..30ebb0d7f8 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -407,9 +407,13 @@ void Application::renameDocument(const char *OldName, const char *NewName) Document* Application::newDocument(const char * Name, const char * UserName, bool createView, bool tempDoc) { + bool defaultConstructor= false; // get a valid name anyway! if (!Name || Name[0] == '\0') + { Name = "Unnamed"; + defaultConstructor= true; //we have function call like newDocument(); + } string name = getUniqueDocumentName(Name, tempDoc); // return the temporary document if it exists @@ -424,7 +428,14 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo userName = UserName; } else { - userName = Name; + if (defaultConstructor) //we have function call newDocument() thus set internal name to "Unnamed" and userName to translated string "Unnamed" + { + QString L10nUserName = QObject::tr("Unnamed"); + userName = L10nUserName.toStdString().c_str(); + } + else { + userName = Name; + } std::vector names; names.reserve(DocMap.size()); std::map::const_iterator pos; diff --git a/src/App/Resources/translations/App.ts b/src/App/Resources/translations/App.ts new file mode 100644 index 0000000000..54d30d1e2c --- /dev/null +++ b/src/App/Resources/translations/App.ts @@ -0,0 +1,21 @@ + + + + + LinkParams + + + Stores the last user choice of whether to apply CopyOnChange setup to all link +that links to the same configurable object + + + + + QObject + + + Unnamed + + + + diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 2b4feb1cde..ff1d0a78fc 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -603,8 +603,7 @@ void StdCmdNew::activated(int iMsg) { Q_UNUSED(iMsg); QString cmd; - cmd = QString::fromLatin1("App.newDocument(\"%1\")") - .arg(qApp->translate("StdCmdNew","Unnamed")); + cmd = QString::fromLatin1("App.newDocument()"); runCommand(Command::Doc,cmd.toUtf8()); doCommand(Command::Gui,"Gui.activeDocument().activeView().viewDefaultOrientation()"); diff --git a/src/Mod/Fem/App/AppFemPy.cpp b/src/Mod/Fem/App/AppFemPy.cpp index 937d99fb30..ef692999a1 100644 --- a/src/Mod/Fem/App/AppFemPy.cpp +++ b/src/Mod/Fem/App/AppFemPy.cpp @@ -112,7 +112,7 @@ private: mesh->read(EncodedName.c_str()); Base::FileInfo file(EncodedName.c_str()); // create new document and add Import feature - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(); FemMeshObject *pcFeature = static_cast (pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str())); pcFeature->Label.setValue(file.fileNamePure().c_str()); diff --git a/src/Mod/Import/App/AppImportPy.cpp b/src/Mod/Import/App/AppImportPy.cpp index 4c4b671da8..0eda0a087d 100644 --- a/src/Mod/Import/App/AppImportPy.cpp +++ b/src/Mod/Import/App/AppImportPy.cpp @@ -159,7 +159,7 @@ private: pcDoc = App::GetApplication().getDocument(DocName); } if (!pcDoc) { - pcDoc = App::GetApplication().newDocument("Unnamed"); + pcDoc = App::GetApplication().newDocument(); } Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication(); diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index c8d61826a1..0bf09ed12f 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -424,7 +424,7 @@ private: pcDoc = App::GetApplication().getDocument(DocName); } if (!pcDoc) { - pcDoc = App::GetApplication().newDocument("Unnamed"); + pcDoc = App::GetApplication().newDocument(); } Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication(); diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index e88848231d..9196910800 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -175,7 +175,7 @@ private: PyMem_Free(Name); // create new document and add Import feature - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(); Mesh::Importer import(pcDoc); import.load(EncodedName); diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index 7e0df3738b..ca9ce43b56 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -735,7 +735,7 @@ private: if (file.hasExtension("stp") || file.hasExtension("step")) { // create new document and add Import feature - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(); #if 1 ImportStepParts(pcDoc,EncodedName.c_str()); #else @@ -746,7 +746,7 @@ private: } #if 1 else if (file.hasExtension("igs") || file.hasExtension("iges")) { - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(); ImportIgesParts(pcDoc,EncodedName.c_str()); pcDoc->recompute(); } diff --git a/src/Mod/Path/Gui/AppPathGuiPy.cpp b/src/Mod/Path/Gui/AppPathGuiPy.cpp index 5772dccbd5..8077b8dd7a 100644 --- a/src/Mod/Path/Gui/AppPathGuiPy.cpp +++ b/src/Mod/Path/Gui/AppPathGuiPy.cpp @@ -104,7 +104,7 @@ private: std::ostringstream pre; std::ostringstream cmd; if (processor.empty()) { - App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + App::Document *pcDoc = App::GetApplication().newDocument(); Gui::Command::runCommand(Gui::Command::Gui,"import Path"); cmd << "Path.read(\"" << EncodedName << "\",\"" << pcDoc->getName() << "\")"; Gui::Command::runCommand(Gui::Command::Gui,cmd.str().c_str()); diff --git a/src/Mod/Points/App/AppPointsPy.cpp b/src/Mod/Points/App/AppPointsPy.cpp index aba6213f94..751af38549 100644 --- a/src/Mod/Points/App/AppPointsPy.cpp +++ b/src/Mod/Points/App/AppPointsPy.cpp @@ -113,7 +113,7 @@ private: reader->read(EncodedName); - App::Document* pcDoc = App::GetApplication().newDocument("Unnamed"); + App::Document* pcDoc = App::GetApplication().newDocument(); Points::Feature* pcFeature = nullptr; if (reader->hasProperties()) { diff --git a/src/Tools/updatets.py b/src/Tools/updatets.py index 99a13e44c3..8977e86a95 100755 --- a/src/Tools/updatets.py +++ b/src/Tools/updatets.py @@ -57,6 +57,7 @@ import re import pathlib directories = [ + {"tsname":"App", "workingdir":"./src/App", "tsdir":"Resources/translations"}, {"tsname":"FreeCAD", "workingdir":"./src/Gui", "tsdir":"Language"}, {"tsname":"AddonManager", "workingdir":"./src/Mod/AddonManager/", "tsdir":"Resources/translations"}, {"tsname":"Arch", "workingdir":"./src/Mod/Arch/", "tsdir":"Resources/translations"},