SHAPER  9.12.0
Config_Translator.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef Config_Translator_H
21 #define Config_Translator_H
22 
23 #include "Config_def.h"
24 #include <Events_InfoMessage.h>
25 
26 #include <string>
27 #include <map>
28 
29 
31 //#define MISSED_TRANSLATION
32 
40 {
41 public:
43  typedef std::map<std::string, std::string> Dictionary;
44 
46  typedef std::map<std::string, Dictionary> Translator;
47 
52  static CONFIG_EXPORT bool load(const std::string& theFileName);
53 
60  static CONFIG_EXPORT std::string translate(const Events_InfoMessage& theInfo);
61 
70  static CONFIG_EXPORT std::string translate(const std::string& theContext,
71  const std::string& theMessage,
72  const std::list<std::string>& theParams = std::list<std::string>());
73 
74 
79  static CONFIG_EXPORT std::string codec(const std::string& theContext);
80 
85  static CONFIG_EXPORT std::string codec(const Events_InfoMessage& theInfo);
86 
87 #ifdef _DEBUG
88 #ifdef MISSED_TRANSLATION
89  static CONFIG_EXPORT void saveMissedTranslations();
90 #endif
91 #endif
92 
93 
94 private:
96  static Translator myTranslator;
97 
99  static Dictionary myCodecs;
100 
101 #ifdef _DEBUG
102 #ifdef MISSED_TRANSLATION
103  static Translator myMissed;
104 #endif
105 #endif
106 };
107 
108 #endif
The definition provides collection and writing of missed translations.
Definition: Config_Translator.h:40
std::map< std::string, std::string > Dictionary
A data type of dictionary <KeyString, ResultString>
Definition: Config_Translator.h:43
static bool load(const std::string &theFileName)
Load translations from TS file.
Definition: Config_Translator.cpp:92
static std::string codec(const std::string &theContext)
Returns codec for the context.
Definition: Config_Translator.cpp:179
std::map< std::string, Dictionary > Translator
A data type of Translator with structure <Context, Dictionary>
Definition: Config_Translator.h:46
static std::string translate(const Events_InfoMessage &theInfo)
Returns translation from the given info message.
Definition: Config_Translator.cpp:123
An event message for sending a string message which has to be translated.
Definition: Events_InfoMessage.h:35