URL-not-found message went into i18n JSON resource

Yet, the URL-not-found message is not yet fully internationalized
since its usage is hardcoded to English.
This commit is contained in:
Veloman Yunkan 2022-03-24 19:37:56 +04:00 committed by Matthieu Gautier
parent 577b6e29f9
commit 202ec81d8b
3 changed files with 9 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#include "request_context.h" #include "request_context.h"
#include "internalServer.h" #include "internalServer.h"
#include "kiwixlib-resources.h" #include "kiwixlib-resources.h"
#include "i18n.h"
#include "tools/regexTools.h" #include "tools/regexTools.h"
#include "tools/stringTools.h" #include "tools/stringTools.h"
@ -131,8 +132,12 @@ HTTP404HtmlResponse::HTTP404HtmlResponse(const InternalServer& server,
HTTPErrorHtmlResponse& HTTP404HtmlResponse::operator+(UrlNotFoundMsg /*unused*/) HTTPErrorHtmlResponse& HTTP404HtmlResponse::operator+(UrlNotFoundMsg /*unused*/)
{ {
const std::string requestUrl = m_request.get_full_url(); const std::string requestUrl = m_request.get_full_url();
kainjow::mustache::mustache msgTmpl(R"(The requested URL "{{url}}" was not found on this server.)"); const auto urlNotFoundMsg = i18n::expandParameterizedString(
return *this + msgTmpl.render({"url", requestUrl}); "en", // FIXME: hardcoded language
"url-not-found",
{{"url", requestUrl}}
);
return *this + urlNotFoundMsg;
} }
HTTPErrorHtmlResponse& HTTPErrorHtmlResponse::operator+(const std::string& msg) HTTPErrorHtmlResponse& HTTPErrorHtmlResponse::operator+(const std::string& msg)

View File

@ -5,4 +5,5 @@
}, },
"name":"English", "name":"English",
"suggest-full-text-search": "containing '{{{SEARCH_TERMS}}}'..." "suggest-full-text-search": "containing '{{{SEARCH_TERMS}}}'..."
, "url-not-found" : "The requested URL \"{{url}}\" was not found on this server."
} }

View File

@ -6,4 +6,5 @@
}, },
"name": "Current language to which the string is being translated to.", "name": "Current language to which the string is being translated to.",
"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"
, "url-not-found" : "Error text about wrong URL for an HTTP 404 error"
} }