Enabled frontend-side translation of 500 error page

This commit is contained in:
Veloman Yunkan 2024-01-17 16:49:02 +04:00 committed by Matthieu Gautier
parent bb1a730253
commit 13a6863183
3 changed files with 9 additions and 2 deletions

View File

@ -431,7 +431,9 @@ HTTP500Response::HTTP500Response(const RequestContext& request)
: HTTPErrorResponse(request, : HTTPErrorResponse(request,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
"500-page-title", "500-page-title",
"500-page-heading") "500-page-heading",
std::string(),
/*includeKiwixResponseData=*/true)
{ {
*this += nonParameterizedMessage("500-page-text"); *this += nonParameterizedMessage("500-page-text");
} }

View File

@ -1036,7 +1036,10 @@ TEST_F(ServerTest, 500)
<head> <head>
<meta content="text/html;charset=UTF-8" http-equiv="content-type" /> <meta content="text/html;charset=UTF-8" http-equiv="content-type" />
<title>Internal Server Error</title> <title>Internal Server Error</title>
<script>
window.KIWIX_RESPONSE_TEMPLATE = )" + ERROR_HTML_TEMPLATE_JS_STRING + R"(;
window.KIWIX_RESPONSE_DATA = { "CSS_URL" : false, "PAGE_HEADING" : { "msgid" : "500-page-heading", "params" : { } }, "PAGE_TITLE" : { "msgid" : "500-page-title", "params" : { } }, "details" : [ { "p" : { "msgid" : "500-page-text", "params" : { } } }, { "p" : { "msgid" : "non-translated-text", "params" : { "MSG" : "Entry redirect_loop.html is a redirect entry." } } } ] };
</script>
</head> </head>
<body> <body>
<h1>Internal Server Error</h1> <h1>Internal Server Error</h1>

View File

@ -190,3 +190,5 @@ protected:
zfs1_.reset(); zfs1_.reset();
} }
}; };
static const std::string ERROR_HTML_TEMPLATE_JS_STRING = R"("&lt;!DOCTYPE html&gt;\n&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;\n &lt;head&gt;\n &lt;meta content=&quot;text/html;charset=UTF-8&quot; http-equiv=&quot;content-type&quot; /&gt;\n &lt;title&gt;{{PAGE_TITLE}}&lt;/title&gt;\n{{#CSS_URL}}\n &lt;link type=&quot;text/css&quot; href=&quot;{{{CSS_URL}}}&quot; rel=&quot;Stylesheet&quot; /&gt;\n{{/CSS_URL}}{{#KIWIX_RESPONSE_DATA}} &lt;script&gt;\n window.KIWIX_RESPONSE_TEMPLATE = &quot;{{KIWIX_RESPONSE_TEMPLATE}}&quot;;\n window.KIWIX_RESPONSE_DATA = {{{KIWIX_RESPONSE_DATA}}};\n &lt;/script&gt;{{/KIWIX_RESPONSE_DATA}}\n &lt;/head&gt;\n &lt;body&gt;\n &lt;h1&gt;{{PAGE_HEADING}}&lt;/h1&gt;\n{{#details}}\n &lt;p&gt;\n {{{p}}}\n &lt;/p&gt;\n{{/details}}\n &lt;/body&gt;\n&lt;/html&gt;\n")";