From 202ec81d8bc2f03e389d66e9ab413affccb16e59 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Thu, 24 Mar 2022 19:37:56 +0400 Subject: [PATCH] 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. --- src/server/response.cpp | 9 +++++++-- static/i18n/en.json | 1 + static/i18n/qqq.json | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/server/response.cpp b/src/server/response.cpp index f87ffecb..795ec7dc 100644 --- a/src/server/response.cpp +++ b/src/server/response.cpp @@ -21,6 +21,7 @@ #include "request_context.h" #include "internalServer.h" #include "kiwixlib-resources.h" +#include "i18n.h" #include "tools/regexTools.h" #include "tools/stringTools.h" @@ -131,8 +132,12 @@ HTTP404HtmlResponse::HTTP404HtmlResponse(const InternalServer& server, HTTPErrorHtmlResponse& HTTP404HtmlResponse::operator+(UrlNotFoundMsg /*unused*/) { const std::string requestUrl = m_request.get_full_url(); - kainjow::mustache::mustache msgTmpl(R"(The requested URL "{{url}}" was not found on this server.)"); - return *this + msgTmpl.render({"url", requestUrl}); + const auto urlNotFoundMsg = i18n::expandParameterizedString( + "en", // FIXME: hardcoded language + "url-not-found", + {{"url", requestUrl}} + ); + return *this + urlNotFoundMsg; } HTTPErrorHtmlResponse& HTTPErrorHtmlResponse::operator+(const std::string& msg) diff --git a/static/i18n/en.json b/static/i18n/en.json index 6a111b28..4b87abe0 100644 --- a/static/i18n/en.json +++ b/static/i18n/en.json @@ -5,4 +5,5 @@ }, "name":"English", "suggest-full-text-search": "containing '{{{SEARCH_TERMS}}}'..." + , "url-not-found" : "The requested URL \"{{url}}\" was not found on this server." } diff --git a/static/i18n/qqq.json b/static/i18n/qqq.json index f0aaaa8d..f62e435e 100644 --- a/static/i18n/qqq.json +++ b/static/i18n/qqq.json @@ -6,4 +6,5 @@ }, "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" + , "url-not-found" : "Error text about wrong URL for an HTTP 404 error" }