/**
* Returns translation from the given data.
- * If transdlation is not exists then it returns a string
+ * If translation is not exists then it returns a string
* from the info data without translation
* \param theContext context of the message (Feature Id)
* \param theMessage a message which dave to be translated
#include <Config_PointerMessage.h>
#include <Config_WidgetReader.h>
#include <Config_ModuleReader.h>
-#include <Config_Translator.h>
#include <QAction>
#include <QMainWindow>
#include <QLayout>
#include <QDialogButtonBox>
#include <QPushButton>
-#include <QTextCodec>
ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
: QObject(theParent), myWorkshop(theParent)
QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature)
{
- QString aMsg = ModelAPI_Tools::getFeatureError(theFeature).c_str();
- if (!aMsg.isEmpty()) {
- std::string aStr = Config_Translator::translate(theFeature->getKind(), aMsg.toStdString());
- std::string aCodec = Config_Translator::codec(theFeature->getKind());
- aMsg = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str());
- }
- return aMsg;
+ std::string aMsg = ModelAPI_Tools::getFeatureError(theFeature);
+ ModuleBase_Tools::translate(theFeature->getKind(), aMsg);
+
+ return aMsg.c_str();
}
void ModuleBase_IModule::grantedOperationIds(ModuleBase_Operation* theOperation,
return true;
std::string anError = ModelAPI_Tools::getFeatureError(myFeature);
+ ModuleBase_Tools::translate(myFeature->getKind(), anError);
return anError.empty();
}
#include <GeomAPI_ShapeExplorer.h>
#include <Config_PropManager.h>
+#include <Config_Translator.h>
#include <QWidget>
#include <QLayout>
#include <QApplication>
#include <QMessageBox>
#include <QAction>
+#include <QTextCodec>
#include <sstream>
#include <string>
}
}
+void translate(const std::string& theContext, std::string& theMessage)
+{
+ if (!theMessage.empty()) {
+ std::string aStr = Config_Translator::translate(theContext, theMessage);
+ if (!aStr.empty()) {
+ std::string aCodec = Config_Translator::codec(theContext);
+ theMessage = QTextCodec::codecForName(aCodec.c_str())->toUnicode(aStr.c_str()).toStdString();
+ }
+ }
+}
+
} // namespace ModuleBase_Tools
/// \param theFeatures an out conteiner of features
void MODULEBASE_EXPORT convertToFeatures(const QObjectPtrList& theObjects, std::set<FeaturePtr>& theFeatures);
+
+/// Returns translation from the given data.
+/// If translation is not exists then it returns a string
+/// from the info data without translation
+/// \param theContext context of the message (Feature Id)
+/// \param theMessage a message which dave to be translated
+/// \param theParams a list of parameters (can be empty)
+void MODULEBASE_EXPORT translate(const std::string& theContext, std::string& theMessage);
+
}
#endif
if (aStrAttr.get()) {
aMsg = aStrAttr->value();
}
+ ModuleBase_Tools::translate(myFeature->getKind(), aMsg);
myLabel->setText(aMsg.c_str());
}
return true;
QString PartSet_SketcherMgr::getFeatureError(const FeaturePtr& theFeature)
{
- QString anError = "";
+ std::string anError = "";
if (!theFeature.get() || !theFeature->data()->isValid())
- return anError;
+ return anError.c_str();
CompositeFeaturePtr aSketch = activeSketch();
if (aSketch.get() && aSketch == theFeature) {
AttributeStringPtr aAttributeString = aSketch->string(SketchPlugin_Sketch::SOLVER_ERROR());
- anError = aAttributeString->value().c_str();
+ anError = aAttributeString->value();
+ ModuleBase_Tools::translate(aSketch->getKind(), anError);
}
- return anError;
+ return anError.c_str();
}
void PartSet_SketcherMgr::clearClickedFlags()
GeomDataAPI
)
+SET(TEXT_RESOURCES
+ SketchSolver_msg_en.ts
+)
+
INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/src/Config
${PROJECT_SOURCE_DIR}/src/SketchPlugin
${PROJECT_SOURCE_DIR}/src/Events
)
+SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES})
+
ADD_DEFINITIONS(-DSKETCHSOLVER_EXPORTS)
-ADD_LIBRARY(SketchSolver SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}
+ADD_LIBRARY(SketchSolver SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${TEXT_RESOURCES}
)
TARGET_LINK_LIBRARIES(SketchSolver ${PROJECT_LIBRARIES}
)
INSTALL(TARGETS SketchSolver DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES})
+INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
# Include specific solvers
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+ <context>
+ <name>Sketch</name>
+ <message>
+ <source>The constraint is conflicting with others. To fix this, you can either undo your operation or remove a conflicting constraint.</source>
+ <translation>The constraint is conflicting with others. To fix this, you can either undo your operation or remove a conflicting constraint.</translation>
+ </message>
+ <message>
+ <source>Caution: SolveSpace crash! Constraints are wrong</source>
+ <translation>Caution: SolveSpace crash! Constraints are wrong</translation>
+ </message>
+ </context>
+</TS>
+