help3xsl/help2.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
New commits: commit af2f7973d5fc5bbf5cd99cc02a450783d34096ea Author: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> AuthorDate: Mon May 12 15:15:54 2025 +0300 Commit: Olivier Hallot <olivier.hal...@libreoffice.org> CommitDate: Mon May 26 15:26:59 2025 +0200 tdf#166353 Simplify getting current language, don't use en-US fallback As en-US might not be installed offline, this was not a working approach. The XSLT to HTML generator makes sure the html element has a language attribute, so just read that. Change-Id: I2b2857ac7ddd5e056ebb7fbb74f782abf58ed229 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/185211 Reviewed-by: Olivier Hallot <olivier.hal...@libreoffice.org> Tested-by: Olivier Hallot <olivier.hal...@libreoffice.org> Tested-by: Jenkins diff --git a/help3xsl/help2.js b/help3xsl/help2.js index 705b666476..66b6398347 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -126,6 +126,10 @@ function getParameterByName(name, url) { return decodeURIComponent(results[2].replace(/\+/g, " ")); } +// This is used when arriving the first time via the application +// or direct access to web root, e.g. a web search. It should not +// be used outside of online context as then we can not guarantee +// en-US as a fallback language. function existingLang(lang) { if (lang === undefined) { return 'en-US'; @@ -223,7 +227,7 @@ if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) < 960 } const href = window.location.href; -const lang = existingLang(getParameterByName("Language", href) || navigator.language); +const lang = getParameterByName("Language", href) || document.querySelector("html").getAttribute("lang"); setupModules(lang); setupLanguages(href);