diff --git a/src/server/i18n.h b/src/server/i18n.h index 955f1309..3a3698f9 100644 --- a/src/server/i18n.h +++ b/src/server/i18n.h @@ -50,6 +50,20 @@ std::string expandParameterizedString(const std::string& lang, const std::string& key, const Parameters& params); +class GetTranslatedString +{ +public: + explicit GetTranslatedString(const std::string& lang) : m_lang(lang) {} + + std::string operator()(const std::string& key) const + { + return getTranslatedString(m_lang, key); + } + +private: + const std::string m_lang; +}; + } // namespace i18n struct ParameterizedMessage diff --git a/src/server/response.cpp b/src/server/response.cpp index ca157b86..56675c75 100644 --- a/src/server/response.cpp +++ b/src/server/response.cpp @@ -280,14 +280,16 @@ void print_response_info(int retCode, MHD_Response* response) } -void ContentResponse::introduce_taskbar() +void ContentResponse::introduce_taskbar(const std::string& lang) { + i18n::GetTranslatedString t(lang); kainjow::mustache::data data; data.set("root", m_root); data.set("content", m_bookName); data.set("hascontent", (!m_bookName.empty() && !m_bookTitle.empty())); data.set("title", m_bookTitle); data.set("withlibrarybutton", m_withLibraryButton); + data.set("LIBRARY_BUTTON_TEXT", t("library-button-text")); auto head_content = render_template(RESOURCE::templates::head_taskbar_html, data); m_content = prependToFirstOccurence( m_content, @@ -352,7 +354,7 @@ ContentResponse::create_mhd_response(const RequestContext& request) inject_root_link(); if (m_withTaskbar) { - introduce_taskbar(); + introduce_taskbar(request.get_user_language()); } if (m_blockExternalLinks) { inject_externallinks_blocker(); diff --git a/src/server/response.h b/src/server/response.h index 9351cf6d..2eba46d2 100644 --- a/src/server/response.h +++ b/src/server/response.h @@ -106,7 +106,7 @@ class ContentResponse : public Response { private: MHD_Response* create_mhd_response(const RequestContext& request); - void introduce_taskbar(); + void introduce_taskbar(const std::string& lang); void inject_externallinks_blocker(); void inject_root_link(); bool can_compress(const RequestContext& request) const; diff --git a/static/i18n/en.json b/static/i18n/en.json index 4b4f4f74..2f24a1a4 100644 --- a/static/i18n/en.json +++ b/static/i18n/en.json @@ -19,4 +19,5 @@ , "500-page-heading" : "Internal Server Error" , "fulltext-search-unavailable" : "Fulltext search unavailable" , "no-search-results": "The fulltext search engine is not available for this content." + , "library-button-text": "Go to welcome page" } diff --git a/static/i18n/hy.json b/static/i18n/hy.json index 6120c2f0..6fd47336 100644 --- a/static/i18n/hy.json +++ b/static/i18n/hy.json @@ -9,4 +9,5 @@ , "url-not-found" : "Սխալ հասցե՝ {{url}}" , "404-page-title" : "Սխալ հասցե" , "404-page-heading" : "Սխալ հասցե" + , "library-button-text": "Գրադարանի էջ" } diff --git a/static/i18n/qqq.json b/static/i18n/qqq.json index ff467cbe..20860ed5 100644 --- a/static/i18n/qqq.json +++ b/static/i18n/qqq.json @@ -20,4 +20,5 @@ , "500-page-heading" : "Heading of the 500 error page" , "fulltext-search-unavailable" : "Title of the error page returned when search is attempted in a book without fulltext search database" , "no-search-results": "Text of the error page returned when search is attempted in a book without fulltext search database" + , "library-button-text": "Tooltip of the button leading to the welcome page" } diff --git a/static/templates/taskbar_part.html b/static/templates/taskbar_part.html index 4ad99ad0..b3268769 100644 --- a/static/templates/taskbar_part.html +++ b/static/templates/taskbar_part.html @@ -12,7 +12,7 @@