diff --git a/src/search_renderer.cpp b/src/search_renderer.cpp index 3b2ae161b..b42275c73 100644 --- a/src/search_renderer.cpp +++ b/src/search_renderer.cpp @@ -32,9 +32,23 @@ #include "libkiwix-resources.h" #include "tools/stringTools.h" +#include "server/i18n.h" + namespace kiwix { +namespace +{ + +ParameterizedMessage searchResultsPageTitleMsg(const std::string& searchPattern) +{ + return ParameterizedMessage("search-results-page-title", + {{"SEARCH_PATTERN", searchPattern}} + ); +} + +} // unnamed namespace + /* Constructor */ SearchRenderer::SearchRenderer(zim::SearchResultSet srs, unsigned int start, unsigned int estimatedResultCount) @@ -159,6 +173,7 @@ kainjow::mustache::data buildPagination( std::string SearchRenderer::renderTemplate(const std::string& tmpl_str, const NameMapper& nameMapper, const Library* library) { + const std::string userlang("en"); const std::string absPathPrefix = protocolPrefix; // Build the results list kainjow::mustache::data items{kainjow::mustache::data::type::list}; @@ -199,11 +214,13 @@ std::string SearchRenderer::renderTemplate(const std::string& tmpl_str, const Na ); - kainjow::mustache::data allData; - allData.set("searchProtocolPrefix", searchProtocolPrefix); - allData.set("results", results); - allData.set("pagination", pagination); - allData.set("query", query); + const kainjow::mustache::object allData{ + {"PAGE_TITLE", searchResultsPageTitleMsg(searchPattern).getText(userlang)}, + {"searchProtocolPrefix", searchProtocolPrefix}, + {"results", results}, + {"pagination", pagination}, + {"query", query}, + }; kainjow::mustache::mustache tmpl(tmpl_str); diff --git a/static/skin/i18n/en.json b/static/skin/i18n/en.json index 8c4a6b0bc..d54c4cd1d 100644 --- a/static/skin/i18n/en.json +++ b/static/skin/i18n/en.json @@ -25,6 +25,7 @@ , "500-page-text": "An internal server error occured. We are sorry about that :/" , "fulltext-search-unavailable" : "Fulltext search unavailable" , "no-search-results": "The fulltext search engine is not available for this content." + , "search-results-page-title": "Search: {{SEARCH_PATTERN}}" , "library-button-text": "Go to welcome page" , "home-button-text": "Go to the main page of '{{BOOK_TITLE}}'" , "random-page-button-text": "Go to a randomly selected page" diff --git a/static/skin/i18n/qqq.json b/static/skin/i18n/qqq.json index 386ee1972..cc44ee4b7 100644 --- a/static/skin/i18n/qqq.json +++ b/static/skin/i18n/qqq.json @@ -29,6 +29,7 @@ "500-page-text": "Text 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", + "search-results-page-title": "Title of the search results page", "library-button-text": "Tooltip of the button leading to the welcome page", "home-button-text": "Tooltip of the button leading to the main page of a book", "random-page-button-text": "Tooltip of the button opening a randomly selected page", diff --git a/static/templates/search_result.html b/static/templates/search_result.html index 93133c584..1ef23007e 100644 --- a/static/templates/search_result.html +++ b/static/templates/search_result.html @@ -102,7 +102,7 @@ } -