Mercurial > thymian
comparison server/main_sender.cpp @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 #include "main_sender.h" | |
| 2 #include <templater.h> | |
| 3 #include <log.h> | |
| 4 #include <unistd.h> | |
| 5 #include <fstream> | |
| 6 | |
| 7 main_sender::main_sender(tnt::HttpRequest& request, tnt::HttpReply& reply, const std::string& what) | |
| 8 : web_component(request, reply, "") | |
| 9 { | |
| 10 std::string targetLanguage = what.substr(1); | |
| 11 | |
| 12 prepareLanguages(); | |
| 13 template_vector_par tvp_languages("languages", m_languageStructs); | |
| 14 | |
| 15 | |
| 16 auto t = translator<mainpage>(); | |
| 17 m_translated = t.templatize(tvp_languages).set().translate(targetLanguage); | |
| 18 auto translations = t.get_translations(); | |
| 19 | |
| 20 stringholder sh(m_translated); | |
| 21 sh.replace_all("{#jsfun}", prepareLangJs(translations)); | |
| 22 sh.replace_all("{#divChanger}", "changeDivs('" + targetLanguage + "');"); | |
| 23 m_translated = sh.get(); | |
| 24 | |
| 25 } | |
| 26 | |
| 27 unsigned main_sender::send() | |
| 28 { | |
| 29 mreply.out() << m_translated; | |
| 30 return HTTP_OK; | |
| 31 } |
