ferencd@0: #include "dictionary.h" ferencd@0: ferencd@0: #include ferencd@0: #include ferencd@0: ferencd@0: const std::vector dictionary::supported_languages = {"gb", "no"}; ferencd@0: std::map> dictionary::m_inMemoryTranslations; ferencd@0: ferencd@0: template ferencd@0: std::string join(const std::vector in, ferencd@0: const std::string & separator =", ", // see 1. ferencd@0: const std::string & concluder =" ") // see 1. ferencd@0: { ferencd@0: std::ostringstream ss; ferencd@0: std::size_t i = 0; ferencd@0: for(; i &translations) ferencd@0: { ferencd@0: std::string result_translation; ferencd@0: bool found = false; ferencd@0: ferencd@0: try { ferencd@0: tntdb::Connection conn = tntdb::connect("sqlite:lang.db"); ferencd@0: ferencd@0: // TODO: prepared statement ferencd@0: ferencd@0: std::string v = "select " + join(supported_languages) + " from translations where source='" + what + "'"; ferencd@0: tntdb::Result result = conn.select(v); ferencd@0: for (tntdb::Result::const_iterator it = result.begin(); it != result.end(); ++it) ferencd@0: { ferencd@0: tntdb::Row row = *it; ferencd@0: ferencd@0: for(size_t i=0; i translations; ferencd@0: return translate(what, target_language, false, translations); ferencd@0: } ferencd@0: ferencd@0: void dictionary::add_translation(const std::string &key, const std::string &language, const std::string &translated) ferencd@0: { ferencd@0: m_inMemoryTranslations[key][language] = translated; ferencd@0: }