1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef Config_Translator_H
21 #define Config_Translator_H
23 #include "Config_def.h"
24 #include <Events_InfoMessage.h>
30 /// The definition provides collection and writing of missed translations
31 //#define MISSED_TRANSLATION
34 * \class Config_Translator
36 * \brief Class for messages translation on different languages. It can load TS
37 * files wich contain translation string and provides translations of messages from source code
39 class Config_Translator
42 /// A data type of dictionary <KeyString, ResultString>
43 typedef std::map<std::string, std::string> Dictionary;
45 /// A data type of Translator with structure <Context, Dictionary>
46 typedef std::map<std::string, Dictionary> Translator;
49 * Load translations from TS file
50 * \param theFileName a TS file name with full path
52 static CONFIG_EXPORT bool load(const std::string& theFileName);
55 * Returns translation from the given info message.
56 * If translation is not exists then it returns a string
57 * from the info data without translation
58 * \param theInfo an info message
60 static CONFIG_EXPORT std::string translate(const Events_InfoMessage& theInfo);
63 * Returns translation from the given data.
64 * If translation is not exists then it returns a string
65 * from the info data without translation
66 * \param theContext context of the message (Feature Id)
67 * \param theMessage a message which dave to be translated
68 * \param theParams a list of parameters (can be empty)
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>());
76 * Returns codec for the context
77 * \param theContext the context
79 static CONFIG_EXPORT std::string codec(const std::string& theContext);
82 * Returns codec for the context
83 * \param theInfo the info
85 static CONFIG_EXPORT std::string codec(const Events_InfoMessage& theInfo);
88 #ifdef MISSED_TRANSLATION
89 static CONFIG_EXPORT void saveMissedTranslations();
95 /// A map of translations
96 static Translator myTranslator;
98 /// aMap of codecs for contexts
99 static Dictionary myCodecs;
102 #ifdef MISSED_TRANSLATION
103 static Translator myMissed;