Salome HOME
Issue #2120: Crash when creating an arc passing through the arc connected to both...
[modules/shaper.git] / src / Config / Config_Translator.cpp
index 643681be20917c3e2225c807f683f2429abce1a0..40980d113b10dc13f002773bbc352e8761e564cb 100644 (file)
 #include <fstream>
 #include <ostream>
 
+#ifdef WIN32
+#pragma warning(disable : 4996) // for sprintf
+#endif
+
+/**
+ * \class Config_TSReader
+ * \ingroup Config
+ * \brief Class for reading translations from TS files (an XML format).
+ */
 class Config_TSReader : public Config_XMLReader
 {
 public:
+  /// Constructor
+  /// \param theTSFile name of TS file
   Config_TSReader(const std::string& theTSFile) : Config_XMLReader(theTSFile) {}
 
+  /// Returns content of TS file
   const Config_Translator::Translator& translator() const { return myTranslator; }
+
+  /// Returns codecs defined in TS files
   const Config_Translator::Dictionary& codecs() const { return myCodecs; }
 
 protected:
@@ -91,15 +105,14 @@ bool Config_Translator::load(const std::string& theFileName)
   return true;
 }
 
-std::string Config_Translator::translate(std::shared_ptr<Events_InfoMessage> theInfo)
+std::string Config_Translator::translate(const Events_InfoMessage& theInfo)
 {
-  std::string aContext = theInfo->context();
-  std::string aMessage = theInfo->messageString();
-  std::list<std::string> aParameters = theInfo->parameters();
+  std::string aContext = theInfo.context();
+  std::string aMessage = theInfo.messageString();
+  std::list<std::string> aParameters = theInfo.parameters();
   return translate(aContext, aMessage, aParameters);
 }
 
-
 std::string insertParameters(const std::string& theString, const std::list<std::string>& theParams)
 {
   std::string aResult = theString;
@@ -122,7 +135,7 @@ std::string insertParameters(const std::string& theString, const std::list<std::
 }
 
 std::string Config_Translator::translate(const std::string& theContext,
-                                         const std::string& theMessage, 
+                                         const std::string& theMessage,
                                          const std::list<std::string>& theParams)
 {
   if (myTranslator.count(theContext) > 0) {
@@ -131,7 +144,8 @@ std::string Config_Translator::translate(const std::string& theContext,
       if (theParams.size() > 0) {
         aTranslation = insertParameters(aTranslation, theParams);
       }
-      return aTranslation;
+      if (aTranslation.size() > 0)
+        return aTranslation;
     }
   }
   std::string aMsg = theMessage;
@@ -148,10 +162,14 @@ std::string Config_Translator::translate(const std::string& theContext,
 
 
 std::string Config_Translator::codec(const std::string& theContext)
-{ 
-  return (myCodecs.count(theContext) > 0)? myCodecs[theContext] : "UTF-8"; 
+{
+  return (myCodecs.count(theContext) > 0)? myCodecs[theContext] : "UTF-8";
 }
 
+std::string Config_Translator::codec(const Events_InfoMessage& theInfo)
+{
+  return codec(theInfo.context());
+}
 
 #ifdef _DEBUG
 #ifdef MISSED_TRANSLATION