From 64acf693a5f64816b8c40167cf5aaf56d45af132 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 1 Jun 2016 10:25:22 +0300 Subject: [PATCH] Define Translator --- src/Config/Config_Translator.cpp | 45 ++++++++++++++++++ src/Config/Config_Translator.h | 43 +++++++++++++++++ src/Events/Events_InfoMessage.h | 63 +++++++++++++++++++++++++ src/SketchPlugin/SketchPlugin_msg_en.ts | 15 ++++++ 4 files changed, 166 insertions(+) create mode 100644 src/Config/Config_Translator.cpp create mode 100644 src/Config/Config_Translator.h create mode 100644 src/Events/Events_InfoMessage.h create mode 100644 src/SketchPlugin/SketchPlugin_msg_en.ts diff --git a/src/Config/Config_Translator.cpp b/src/Config/Config_Translator.cpp new file mode 100644 index 000000000..9b03dc798 --- /dev/null +++ b/src/Config/Config_Translator.cpp @@ -0,0 +1,45 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: Config_Translator.cpp +// Created: 31 May 2016 +// Author: Vitaly SMETANNIKOV + +#include "Config_Translator.h" +#include + +class Config_TSReader : public Config_XMLReader +{ +public: + Config_TSReader(const std::string& theTSFile) : Config_XMLReader(theTSFile) {} + + const Config_Translator::Translator& translator() const { return myTranslator; } + +protected: + /// Overloaded method. Defines how to process each node + virtual void processNode(xmlNodePtr theNode); +private: + Config_Translator::Translator myTranslator; +}; + +void Config_TSReader::processNode(xmlNodePtr theNode) +{ +} + + +bool Config_Translator::load(const std::string& theFileName) +{ + Config_TSReader aReader(theFileName); + aReader.readAll(); + + const Translator& aTranslator = aReader.translator(); + Translator::const_iterator aIt; + for (aIt = aTranslator.cbegin(); aIt != aTranslator.cend(); aIt++) { + } + + return true; +} + +std::string Config_Translator::translate(const Events_InfoMessage& theInfo) +{ + return ""; +} diff --git a/src/Config/Config_Translator.h b/src/Config/Config_Translator.h new file mode 100644 index 000000000..43350f8f3 --- /dev/null +++ b/src/Config/Config_Translator.h @@ -0,0 +1,43 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: Config_Translator.h +// Created: 31 May 2016 +// Author: Vitaly SMETANNIKOV + +#ifndef Config_Translator_H +#define Config_Translator_H + +#include "Config_def.h" +#include + +#include +#include + +class Config_Translator +{ +public: + /// A data type of dictionary + typedef std::map Dictionary; + + /// A data type of Translator with structure + typedef std::map Translator; + + /** + * Load translations from TS file + * \param theFileName a TS file name with full path + */ + static CONFIG_EXPORT bool load(const std::string& theFileName); + + /** + * Returns translation from the given info message. + * If transdlation is not exists then it returns a string + * from the info data without translation + * \param theInfo an info message + */ + static CONFIG_EXPORT std::string translate(const Events_InfoMessage& theInfo); + +private: + static Translator myTranslator; +}; + +#endif \ No newline at end of file diff --git a/src/Events/Events_InfoMessage.h b/src/Events/Events_InfoMessage.h new file mode 100644 index 000000000..a38bec124 --- /dev/null +++ b/src/Events/Events_InfoMessage.h @@ -0,0 +1,63 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: Events_InfoMessage.hxx +// Created: 31 May 2016 +// Author: Vitaly SMETANNIKOV + +#ifndef Events_InfoMessage_H_ +#define Events_InfoMessage_H_ + +#include +#include +#include + +class EVENTS_EXPORT Events_InfoMessage: public Events_Message +{ +public: + Events_InfoMessage(const void* theSender = 0) : + Events_Message(Events_Loop::eventByName("InfoMessage"), theSender) {} + + void setContext(const std::string& theContext) { myContext = theContext; } + + std::string context() const { return myContext; } + + void setMessage(const std::string& theMsg) { myMessage = theMsg; } + + std::string message() const { return myMessage; } + + void addParameter(const std::string& theParam) + { + myParameters.push_back(theParam); + } + + void addParameter(double theParam) + { + char aBuf[50]; + int n = sprintf(aBuf, "%g", theParam); + std::string aStr(aBuf); + myParameters.push_back(aStr); + } + + void addParameter(int theParam) + { + char aBuf[50]; + int n = sprintf(aBuf, "%d", theParam); + std::string aStr(aBuf); + myParameters.push_back(aStr); + } + + std::list parameters() const { return myParameters; } + +private: + + /// Context of the messgae + std::string myContext; + + /// String of the message + std::string myMessage; + + /// Parameters of the message + std::list myParameters; +}; + +#endif \ No newline at end of file diff --git a/src/SketchPlugin/SketchPlugin_msg_en.ts b/src/SketchPlugin/SketchPlugin_msg_en.ts new file mode 100644 index 000000000..bd3f891bb --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_msg_en.ts @@ -0,0 +1,15 @@ + + + + + SketchConstraintVertical + + Model_FeatureValidator: Attribute "ConstraintEntityA" is not initialized. + Line for constraint is not selected. + + + ModelAPI_StateInvalidArgument + Wrong argument for the constraint + + + -- 2.39.2