mirror of https://github.com/kiwix/libkiwix.git
"Go to welcome page" is internationalized
This commit is contained in:
parent
901664b097
commit
c2bfeb4030
|
@ -50,6 +50,20 @@ std::string expandParameterizedString(const std::string& lang,
|
|||
const std::string& key,
|
||||
const Parameters& params);
|
||||
|
||||
class GetTranslatedString
|
||||
{
|
||||
public:
|
||||
explicit GetTranslatedString(const std::string& lang) : m_lang(lang) {}
|
||||
|
||||
std::string operator()(const std::string& key) const
|
||||
{
|
||||
return getTranslatedString(m_lang, key);
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_lang;
|
||||
};
|
||||
|
||||
} // namespace i18n
|
||||
|
||||
struct ParameterizedMessage
|
||||
|
|
|
@ -280,14 +280,16 @@ void print_response_info(int retCode, MHD_Response* response)
|
|||
}
|
||||
|
||||
|
||||
void ContentResponse::introduce_taskbar()
|
||||
void ContentResponse::introduce_taskbar(const std::string& lang)
|
||||
{
|
||||
i18n::GetTranslatedString t(lang);
|
||||
kainjow::mustache::data data;
|
||||
data.set("root", m_root);
|
||||
data.set("content", m_bookName);
|
||||
data.set("hascontent", (!m_bookName.empty() && !m_bookTitle.empty()));
|
||||
data.set("title", m_bookTitle);
|
||||
data.set("withlibrarybutton", m_withLibraryButton);
|
||||
data.set("LIBRARY_BUTTON_TEXT", t("library-button-text"));
|
||||
auto head_content = render_template(RESOURCE::templates::head_taskbar_html, data);
|
||||
m_content = prependToFirstOccurence(
|
||||
m_content,
|
||||
|
@ -352,7 +354,7 @@ ContentResponse::create_mhd_response(const RequestContext& request)
|
|||
inject_root_link();
|
||||
|
||||
if (m_withTaskbar) {
|
||||
introduce_taskbar();
|
||||
introduce_taskbar(request.get_user_language());
|
||||
}
|
||||
if (m_blockExternalLinks) {
|
||||
inject_externallinks_blocker();
|
||||
|
|
|
@ -106,7 +106,7 @@ class ContentResponse : public Response {
|
|||
private:
|
||||
MHD_Response* create_mhd_response(const RequestContext& request);
|
||||
|
||||
void introduce_taskbar();
|
||||
void introduce_taskbar(const std::string& lang);
|
||||
void inject_externallinks_blocker();
|
||||
void inject_root_link();
|
||||
bool can_compress(const RequestContext& request) const;
|
||||
|
|
|
@ -19,4 +19,5 @@
|
|||
, "500-page-heading" : "Internal Server Error"
|
||||
, "fulltext-search-unavailable" : "Fulltext search unavailable"
|
||||
, "no-search-results": "The fulltext search engine is not available for this content."
|
||||
, "library-button-text": "Go to welcome page"
|
||||
}
|
||||
|
|
|
@ -9,4 +9,5 @@
|
|||
, "url-not-found" : "Սխալ հասցե՝ {{url}}"
|
||||
, "404-page-title" : "Սխալ հասցե"
|
||||
, "404-page-heading" : "Սխալ հասցե"
|
||||
, "library-button-text": "Գրադարանի էջ"
|
||||
}
|
||||
|
|
|
@ -20,4 +20,5 @@
|
|||
, "500-page-heading" : "Heading of the 500 error page"
|
||||
, "fulltext-search-unavailable" : "Title of the error page returned when search is attempted in a book without fulltext search database"
|
||||
, "no-search-results": "Text of the error page returned when search is attempted in a book without fulltext search database"
|
||||
, "library-button-text": "Tooltip of the button leading to the welcome page"
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<label for="kiwix_button_show_toggle"><img src="{{root}}/skin/caret.png" alt=""></label>
|
||||
<div class="kiwix_button_cont">
|
||||
{{#withlibrarybutton}}
|
||||
<a id="kiwix_serve_taskbar_library_button" title="Go to welcome page" aria-label="Go to welcome page" href="{{root}}/"><button>🏠</button></a>
|
||||
<a id="kiwix_serve_taskbar_library_button" title="{{{LIBRARY_BUTTON_TEXT}}}" aria-label="{{{LIBRARY_BUTTON_TEXT}}}" href="{{root}}/"><button>🏠</button></a>
|
||||
{{/withlibrarybutton}}
|
||||
{{#hascontent}}
|
||||
<a id="kiwix_serve_taskbar_home_button" title="Go to the main page of '{{title}}'" aria-label="Go to the main page of '{{title}}'" href="{{root}}/{{content}}/"><button>{{title}}</button></a>
|
||||
|
|
Loading…
Reference in New Issue