Internationalized bad raw access datatype message

This commit is contained in:
Veloman Yunkan 2022-01-23 22:24:30 +04:00 committed by Matthieu Gautier
parent ca7e0fb4a0
commit 779382642b
3 changed files with 8 additions and 2 deletions

View File

@ -462,6 +462,11 @@ std::string noSearchResultsMsg()
return "The fulltext search engine is not available for this content."; return "The fulltext search engine is not available for this content.";
} }
ParameterizedMessage invalidRawAccessMsg(const std::string& dt)
{
return ParameterizedMessage("invalid-raw-data-type", { {"DATATYPE", dt} });
}
ParameterizedMessage nonParameterizedMessage(const std::string& msgId) ParameterizedMessage nonParameterizedMessage(const std::string& msgId)
{ {
return ParameterizedMessage(msgId, {}); return ParameterizedMessage(msgId, {});
@ -924,10 +929,9 @@ std::unique_ptr<Response> InternalServer::handle_raw(const RequestContext& reque
} }
if (kind != "meta" && kind!= "content") { if (kind != "meta" && kind!= "content") {
const std::string error_details = kind + " is not a valid request for raw content.";
return HTTP404HtmlResponse(*this, request) return HTTP404HtmlResponse(*this, request)
+ urlNotFoundMsg + urlNotFoundMsg
+ error_details; + invalidRawAccessMsg(kind);
} }
std::shared_ptr<zim::Archive> archive; std::shared_ptr<zim::Archive> archive;

View File

@ -9,4 +9,5 @@
, "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>" , "suggest-search" : "Make a full text search for <a href=\"{{{SEARCH_URL}}}\">{{PATTERN}}</a>"
, "random-article-failure" : "Oops! Failed to pick a random article :(" , "random-article-failure" : "Oops! Failed to pick a random article :("
, "invalid-raw-data-type" : "{{DATATYPE}} is not a valid request for raw content."
} }

View File

@ -10,4 +10,5 @@
, "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" , "suggest-search" : "Suggest a search when the URL points to a non existing article"
, "random-article-failure" : "Failure of the random article selection procedure" , "random-article-failure" : "Failure of the random article selection procedure"
, "invalid-raw-data-type" : "Invalid DATATYPE was used with the /raw endpoint (/raw/<book>/DATATYPE/...); allowed values are 'meta' and 'content'"
} }