[App] Fix of untranslated first document's name (#7156)
* Change no need function newDocument("Unnamed") call to variant without parameter. "Unnamed" set in App newDocument function instead.
* Refactor New Document command to run without parameter.
* Translate new document's userName. Internal name = "Unnamed".
* Crowdin Add to updatets.py App.ts. Create new file App.ts
* Fix error where document name is set with one function parameter. In this situation set internal and user name to string variable. For default function call (without parameter) set internal name to Unnamed, userName = translate ("Unnamed")
This commit is contained in:
committed by
GitHub
parent
086de5430f
commit
2eb55d48c7
@@ -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<std::string> names;
|
||||
names.reserve(DocMap.size());
|
||||
std::map<string,Document*>::const_iterator pos;
|
||||
|
||||
21
src/App/Resources/translations/App.ts
Normal file
21
src/App/Resources/translations/App.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1">
|
||||
<context>
|
||||
<name>LinkParams</name>
|
||||
<message>
|
||||
<location filename="../../Link.cpp" line="119"/>
|
||||
<source>Stores the last user choice of whether to apply CopyOnChange setup to all link
|
||||
that links to the same configurable object</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>QObject</name>
|
||||
<message>
|
||||
<location filename="../../Application.cpp" line="455"/>
|
||||
<source>Unnamed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
@@ -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()");
|
||||
|
||||
|
||||
@@ -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<FemMeshObject *>
|
||||
(pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
|
||||
pcFeature->Label.setValue(file.fileNamePure().c_str());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user