1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef Config_Translator_H
22 #define Config_Translator_H
24 #include "Config_def.h"
25 #include <Events_InfoMessage.h>
31 /// The definition provides collection and writing of missed translations
32 //#define MISSED_TRANSLATION
35 * \class Config_Translator
37 * \brief Class for messages translation on different languages. It can load TS
38 * files wich contain translation string and provides translations of messages from source code
40 class Config_Translator
43 /// A data type of dictionary <KeyString, ResultString>
44 typedef std::map<std::string, std::string> Dictionary;
46 /// A data type of Translator with structure <Context, Dictionary>
47 typedef std::map<std::string, Dictionary> Translator;
50 * Load translations from TS file
51 * \param theFileName a TS file name with full path
53 static CONFIG_EXPORT bool load(const std::string& theFileName);
56 * Returns translation from the given info message.
57 * If translation is not exists then it returns a string
58 * from the info data without translation
59 * \param theInfo an info message
61 static CONFIG_EXPORT std::string translate(const Events_InfoMessage& theInfo);
64 * Returns translation from the given data.
65 * If translation is not exists then it returns a string
66 * from the info data without translation
67 * \param theContext context of the message (Feature Id)
68 * \param theMessage a message which dave to be translated
69 * \param theParams a list of parameters (can be empty)
71 static CONFIG_EXPORT std::string translate(const std::string& theContext,
72 const std::string& theMessage,
73 const std::list<std::string>& theParams = std::list<std::string>());
77 * Returns codec for the context
78 * \param theContext the context
80 static CONFIG_EXPORT std::string codec(const std::string& theContext);
83 * Returns codec for the context
84 * \param theInfo the info
86 static CONFIG_EXPORT std::string codec(const Events_InfoMessage& theInfo);
89 #ifdef MISSED_TRANSLATION
90 static CONFIG_EXPORT void saveMissedTranslations();
96 /// A map of translations
97 static Translator myTranslator;
99 /// aMap of codecs for contexts
100 static Dictionary myCodecs;
103 #ifdef MISSED_TRANSLATION
104 static Translator myMissed;