1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Config_Translator.h
4 // Created: 31 May 2016
5 // Author: Vitaly SMETANNIKOV
7 #ifndef Config_Translator_H
8 #define Config_Translator_H
10 #include "Config_def.h"
11 #include <Events_InfoMessage.h>
16 //#define MISSED_TRANSLATION
19 * \class Config_Translator
21 * \brief Class for messages translation on different languages. It can load TS
22 * files wich contain translation string and provides translations of messages from source code
24 class Config_Translator
27 /// A data type of dictionary <KeyString, ResultString>
28 typedef std::map<std::string, std::string> Dictionary;
30 /// A data type of Translator with structure <Context, Dictionary>
31 typedef std::map<std::string, Dictionary> Translator;
34 * Load translations from TS file
35 * \param theFileName a TS file name with full path
37 static CONFIG_EXPORT bool load(const std::string& theFileName);
40 * Returns translation from the given info message.
41 * If transdlation is not exists then it returns a string
42 * from the info data without translation
43 * \param theInfo an info message
45 static CONFIG_EXPORT std::string translate(std::shared_ptr<Events_InfoMessage> theInfo);
48 * Returns translation from the given data.
49 * If transdlation is not exists then it returns a string
50 * from the info data without translation
51 * \param theContext context of the message (Feature Id)
52 * \param theMessage a message which dave to be translated
53 * \param theParams a list of parameters (can be empty)
55 static CONFIG_EXPORT std::string translate(const std::string& theContext,
56 const std::string& theMessage,
57 const std::list<std::string>& theParams = std::list<std::string>());
61 * Returns codec for the context
62 * \param theContext the context
64 static CONFIG_EXPORT std::string codec(const std::string& theContext);
67 #ifdef MISSED_TRANSLATION
68 static CONFIG_EXPORT void saveMissedTranslations();
74 /// A map of translations
75 static Translator myTranslator;
77 /// aMap of codecs for contexts
78 static Dictionary myCodecs;
81 #ifdef MISSED_TRANSLATION
82 static Translator myMissed;