forked from amazingfate/help
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.hallot@libreoffice.org> Tested-by: Olivier Hallot <olivier.hallot@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
committed by
Olivier Hallot
parent
3b9dbcec0f
commit
af2f7973d5
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user