mirror of https://github.com/kiwix/libkiwix.git
Internationalized search suggestion message
This commit is contained in:
parent
cb5ae01fd8
commit
1ace16229d
|
@ -823,13 +823,18 @@ std::string get_book_name(const RequestContext& request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ParameterizedMessage suggestSearchMsg(const std::string& searchURL, const std::string& pattern)
|
||||||
|
{
|
||||||
|
return ParameterizedMessage("suggest-search",
|
||||||
|
{
|
||||||
|
{ "PATTERN", pattern },
|
||||||
|
{ "SEARCH_URL", searchURL }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
std::string searchSuggestionHTML(const std::string& searchURL, const std::string& pattern)
|
std::string searchSuggestionHTML(const std::string& searchURL, const std::string& pattern)
|
||||||
{
|
{
|
||||||
kainjow::mustache::mustache tmpl("Make a full text search for <a href=\"{{{searchURL}}}\">{{pattern}}</a>");
|
return suggestSearchMsg(searchURL, pattern).getText("en");
|
||||||
MustacheData data;
|
|
||||||
data.set("pattern", pattern);
|
|
||||||
data.set("searchURL", searchURL);
|
|
||||||
return (tmpl.render(data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // unnamed namespace
|
} // unnamed namespace
|
||||||
|
@ -863,7 +868,7 @@ std::unique_ptr<Response> InternalServer::handle_content(const RequestContext& r
|
||||||
const std::string searchURL = m_root + "/search?pattern=" + kiwix::urlEncode(pattern, true);
|
const std::string searchURL = m_root + "/search?pattern=" + kiwix::urlEncode(pattern, true);
|
||||||
return HTTP404HtmlResponse(*this, request)
|
return HTTP404HtmlResponse(*this, request)
|
||||||
+ urlNotFoundMsg
|
+ urlNotFoundMsg
|
||||||
+ searchSuggestionHTML(searchURL, kiwix::urlDecode(pattern))
|
+ suggestSearchMsg(searchURL, kiwix::urlDecode(pattern))
|
||||||
+ TaskbarInfo(bookName);
|
+ TaskbarInfo(bookName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,5 @@
|
||||||
"suggest-full-text-search": "containing '{{{SEARCH_TERMS}}}'..."
|
"suggest-full-text-search": "containing '{{{SEARCH_TERMS}}}'..."
|
||||||
, "no-such-book": "No such book: {{BOOK_NAME}}"
|
, "no-such-book": "No such book: {{BOOK_NAME}}"
|
||||||
, "url-not-found" : "The requested URL \"{{url}}\" was not found on this server."
|
, "url-not-found" : "The requested URL \"{{url}}\" was not found on this server."
|
||||||
|
, "suggest-search" : "Make a full text search for <a href=\"{{{SEARCH_URL}}}\">{{PATTERN}}</a>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,4 +8,5 @@
|
||||||
"suggest-full-text-search": "Text appearing in the suggestion list that, when selected, runs a full text search instead of the title search"
|
"suggest-full-text-search": "Text appearing in the suggestion list that, when selected, runs a full text search instead of the title search"
|
||||||
, "no-such-book": "Error text when the requested book is not found in the library"
|
, "no-such-book": "Error text when the requested book is not found in the library"
|
||||||
, "url-not-found" : "Error text about wrong URL for an HTTP 404 error"
|
, "url-not-found" : "Error text about wrong URL for an HTTP 404 error"
|
||||||
|
, "suggest-search" : "Suggest a search when the URL points to a non existing article"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue