Search result info as translatable text

However it is NOT actually translated by the backend yet
This commit is contained in:
Veloman Yunkan
2024-01-30 16:21:00 +04:00
parent 8f5714be07
commit 33a3277400
4 changed files with 22 additions and 8 deletions

View File

@ -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);