diff --git a/src/search_renderer.cpp b/src/search_renderer.cpp index bcdb4142f..96392e961 100644 --- a/src/search_renderer.cpp +++ b/src/search_renderer.cpp @@ -204,10 +204,20 @@ std::string SearchRenderer::renderTemplate(const std::string& tmpl_str, const Na result.set("absolutePath", absPathPrefix + urlEncode(path)); result.set("snippet", it.getSnippet()); if (library) { - result.set("bookTitle", library->getBookById(zim_id).getTitle()); + const std::string bookTitle = library->getBookById(zim_id).getTitle(); + const ParameterizedMessage bookInfoMsg("search-result-book-info", + {{"BOOK_TITLE", bookTitle}} + ); + result.set("bookInfo", bookInfoMsg.getText(userlang)); // for HTML + result.set("bookTitle", bookTitle); // for XML } if (it.getWordCount() >= 0) { - result.set("wordCount", kiwix::beautifyInteger(it.getWordCount())); + const auto wordCountStr = kiwix::beautifyInteger(it.getWordCount()); + const ParameterizedMessage wordCountMsg("word-count", + {{"COUNT", wordCountStr}} + ); + result.set("wordCountInfo", wordCountMsg.getText(userlang)); // for HTML + result.set("wordCount", wordCountStr); // for XML } items.push_back(result); diff --git a/static/skin/i18n/en.json b/static/skin/i18n/en.json index 88bfa8608..918304808 100644 --- a/static/skin/i18n/en.json +++ b/static/skin/i18n/en.json @@ -28,6 +28,8 @@ , "search-results-page-title": "Search: {{SEARCH_PATTERN}}" , "search-results-page-header": "Results {{START}}-{{END}} of {{COUNT}} for \"{{{SEARCH_PATTERN}}}\"" , "empty-search-results-page-header": "No results were found for \"{{{SEARCH_PATTERN}}}\"" + , "search-result-book-info": "from {{BOOK_TITLE}}" + , "word-count": "{{COUNT}} words" , "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 923021b8a..9a8c5c144 100644 --- a/static/skin/i18n/qqq.json +++ b/static/skin/i18n/qqq.json @@ -32,6 +32,8 @@ "search-results-page-title": "Title of the search results page", "search-results-page-header": "Header of the search results page", "empty-search-results-page-header": "Header of the empty search results page", + "search-result-book-info": "Reference to the book where the search result belongs (this is displayed AFTER the search result)", + "word-count": "Word count information", "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 9aa440e8c..eac969158 100644 --- a/static/templates/search_result.html +++ b/static/templates/search_result.html @@ -119,12 +119,12 @@ {{#snippet}} {{>snippet}}... {{/snippet}} - {{#bookTitle}} -
from {{bookTitle}}
- {{/bookTitle}} - {{#wordCount}} -
{{wordCount}} words
- {{/wordCount}} + {{#bookInfo}} +
{{bookInfo}}
+ {{/bookInfo}} + {{#wordCountInfo}} +
{{wordCountInfo}}
+ {{/wordCountInfo}} {{/results.items}}