From cadb9e440b560781096f53619b358ef313c042fa Mon Sep 17 00:00:00 2001 From: ShaopengLin Date: Mon, 9 Sep 2024 04:31:00 -0400 Subject: [PATCH] Inject TOC title translation --- resources/js/toc.js | 2 +- src/webpage.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/resources/js/toc.js b/resources/js/toc.js index a0f30980b..95ff7e7b6 100644 --- a/resources/js/toc.js +++ b/resources/js/toc.js @@ -89,7 +89,7 @@ function setupTOC() var tocTitle = document.createElement('p'); tocTitle.id = "kiwix-toc-title"; - tocTitle.textContent = "Contents"; + tocTitle.textContent = KIWIX_GT_CONTENT; toc.prepend(tocTitle); var tocDiv = document.createElement('div'); diff --git a/src/webpage.cpp b/src/webpage.cpp index b4cc4360e..abba46037 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -31,7 +31,11 @@ WebPage::WebPage(QObject *parent) : action(QWebEnginePage::ViewSource)->setVisible(false); action(QWebEnginePage::Reload)->setVisible(false); - scripts().insert(getScript(":/js/toc.js")); + auto tocScript = getScript(":/js/toc.js"); + auto source = tocScript.sourceCode().prepend("const KIWIX_GT_CONTENT = \"" + gt("table-of-content") + "\";"); + tocScript.setSourceCode(source); + qInfo() << source; + scripts().insert(tocScript); scripts().insert(getScript(":/js/tocStyle.js")); }