]> SALOME platform Git repositories - modules/shaper.git/blob - src/Config/Config_Translator.h
Salome HOME
Send information message for translation
[modules/shaper.git] / src / Config / Config_Translator.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Config_Translator.h
4 // Created:     31 May 2016
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef Config_Translator_H
8 #define Config_Translator_H
9
10 #include "Config_def.h"
11 #include <Events_InfoMessage.h>
12
13 #include <string>
14 #include <map>
15
16 /**
17  * \class Config_Translator
18  * \ingroup Config
19  * \brief Class for messages translation on different languages. It can load TS
20  * files wich contain translation string and provides translations of messages from source code
21  */
22 class Config_Translator
23 {
24 public:
25   /// A data type of dictionary <KeyString, ResultString>
26   typedef std::map<std::string, std::string> Dictionary;
27
28   /// A data type of Translator with structure <Context, Dictionary>
29   typedef std::map<std::string, Dictionary> Translator;
30
31   /**
32   * Load translations from TS file
33   * \param theFileName a TS file name with full path
34   */
35   static CONFIG_EXPORT bool load(const std::string& theFileName);
36
37   /**
38   * Returns translation from the given info message.
39   * If transdlation is not exists then it returns a string 
40   * from the info data without translation
41   * \param theInfo an info message
42   */
43   static CONFIG_EXPORT std::string translate(std::shared_ptr<Events_InfoMessage> theInfo);
44
45   /**
46   * Returns translation from the given data.
47   * If transdlation is not exists then it returns a string 
48   * from the info data without translation
49   * \param theContext context of the message (Feature Id)
50   * \param theMessage a message which dave to be translated
51   * \param theParams a list of parameters (can be empty)
52   */
53   static CONFIG_EXPORT std::string translate(const std::string& theContext,
54     const std::string& theMessage, 
55     const std::list<std::string>& theParams = std::list<std::string>());
56
57 private:
58   static Translator myTranslator;
59 };
60
61 #endif