]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Define Translator
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 1 Jun 2016 07:25:22 +0000 (10:25 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 1 Jun 2016 07:25:22 +0000 (10:25 +0300)
src/Config/Config_Translator.cpp [new file with mode: 0644]
src/Config/Config_Translator.h [new file with mode: 0644]
src/Events/Events_InfoMessage.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_msg_en.ts [new file with mode: 0644]

diff --git a/src/Config/Config_Translator.cpp b/src/Config/Config_Translator.cpp
new file mode 100644 (file)
index 0000000..9b03dc7
--- /dev/null
@@ -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 <Config_XMLReader.h>
+
+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 (file)
index 0000000..43350f8
--- /dev/null
@@ -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 <Events_InfoMessage.h>
+
+#include <string>
+#include <map>
+
+class Config_Translator
+{
+public:
+  /// A data type of dictionary <KeyString, ResultString>
+  typedef std::map<std::string, std::string> Dictionary;
+
+  /// A data type of Translator with structure <Context, Dictionary>
+  typedef std::map<std::string, Dictionary> 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 (file)
index 0000000..a38bec1
--- /dev/null
@@ -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 <Events.h>
+#include <Events_Message.h>
+#include <Events_Loop.h>
+
+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<std::string> 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<std::string> 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 (file)
index 0000000..bd3f891
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="en_US">
+<context>
+    <name>SketchConstraintVertical</name>
+    <message>
+        <source>Model_FeatureValidator: Attribute &quot;ConstraintEntityA&quot; is not initialized.</source>
+        <translation>Line for constraint is not selected.</translation>
+    </message>
+    <message>
+        <source>ModelAPI_StateInvalidArgument</source>
+        <translation>Wrong argument for the constraint</translation>
+    </message>
+</context>
+</TS>