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>
17 /// The definition provides collection and writing of missed translations
18 //#define MISSED_TRANSLATION
21 * \class Config_Translator
23 * \brief Class for messages translation on different languages. It can load TS
24 * files wich contain translation string and provides translations of messages from source code
26 class Config_Translator
29 /// A data type of dictionary <KeyString, ResultString>
30 typedef std::map<std::string, std::string> Dictionary;
32 /// A data type of Translator with structure <Context, Dictionary>
33 typedef std::map<std::string, Dictionary> Translator;
36 * Load translations from TS file
37 * \param theFileName a TS file name with full path
39 static CONFIG_EXPORT bool load(const std::string& theFileName);
42 * Returns translation from the given info message.
43 * If translation is not exists then it returns a string
44 * from the info data without translation
45 * \param theInfo an info message
47 static CONFIG_EXPORT std::string translate(const Events_InfoMessage& theInfo);
50 * Returns translation from the given data.
51 * If translation is not exists then it returns a string
52 * from the info data without translation
53 * \param theContext context of the message (Feature Id)
54 * \param theMessage a message which dave to be translated
55 * \param theParams a list of parameters (can be empty)
57 static CONFIG_EXPORT std::string translate(const std::string& theContext,
58 const std::string& theMessage,
59 const std::list<std::string>& theParams = std::list<std::string>());
63 * Returns codec for the context
64 * \param theContext the context
66 static CONFIG_EXPORT std::string codec(const std::string& theContext);
69 * Returns codec for the context
70 * \param theInfo the info
72 static CONFIG_EXPORT std::string codec(const Events_InfoMessage& theInfo);
75 #ifdef MISSED_TRANSLATION
76 static CONFIG_EXPORT void saveMissedTranslations();
82 /// A map of translations
83 static Translator myTranslator;
85 /// aMap of codecs for contexts
86 static Dictionary myCodecs;
89 #ifdef MISSED_TRANSLATION
90 static Translator myMissed;