// // Created by bbr on 14.06.22.. // #ifndef SCHEMEEDITOR_MESSAGE_SOURCE_H #define SCHEMEEDITOR_MESSAGE_SOURCE_H #include #include #include "comdel/domain/value.h" class MessageSource { private: MessageSource() { loadDefaults(); } void add(const std::string& key, std::string message); std::string populateMessage(std::string message, std::map parametars); std::string replacePlaceholder(std::string message, std::string key, std::string value); std::map messages; public: static MessageSource *instance(); static std::map map(std::map values); std::string get(const std::string& key); std::string get(const std::string& key, std::map parametars); void loadDefaults(); void load(std::map messages); }; #define MESSAGE_PARAM(key, params) MessageSource::instance()->get(key, params) #define MESSAGE(key) MessageSource::instance()->get(key) #define MESSAGE_MAP(value) MessageSource::instance()->map(value) #define QMESSAGE_PARAM(key, params) QString::fromStdString(MessageSource::instance()->get(key, params)) #define QMESSAGE(key) QString::fromStdString(MessageSource::instance()->get(key)) #endif //SCHEMEEDITOR_MESSAGE_SOURCE_H