Derp fixes

wasn't actually broken, but I made a couple changes I didn't need to and it looked bad that it would flash English briefly so changed that to an nbsp
This commit is contained in:
Pk11 2021-10-15 22:25:34 -05:00
parent 9ffc156350
commit 16e53dcb82
2 changed files with 4 additions and 6 deletions

View File

@ -1,7 +1,7 @@
<div class="row">
<div class="col-12">
<div id="language-alert" class="alert alert-secondary alert-dismissible fade show d-none mt-3 mb-0" role="alert">
<a id="language-alert-link" href="#" accesskey="l">This page is available in your language!</a>
<a id="language-alert-link" href="#" accesskey="l">&nbsp;</a>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{{ site.data[page.collection].strings.close }}"></button>
</div>
</div>

View File

@ -18,7 +18,7 @@ if(!sessionStorage.languageAlertDismissed) {
if(document.documentElement.lang == "ic-IC") {
languageID = "ic-IC";
// If the current language isn't in the browser's allowed languages, show the popup for the first language that has a page
} else if(!window.navigator.languages.find(function(lang) { return document.documentElement.lang.toLowerCase().includes(lang.toLowerCase()); })) {
} else if(!window.navigator.languages.find(lang => document.documentElement.lang.toLowerCase().includes(lang.toLowerCase()))) {
for(let windowLang of window.navigator.languages) {
let lang = languages.find(lang => lang.substr(0, 2) == windowLang.substr(0, 2));
if(lang) {
@ -49,11 +49,9 @@ if(!sessionStorage.languageAlertDismissed) {
const langAlertLink = document.getElementById("language-alert-link");
// Set text from language file if it exists
import(`./i18n/${languageID}.js`).then(function(obj) {
import(`./i18n/${languageID}.js`).then(obj => {
langAlertLink.innerHTML = obj.default.pageIsInYourLanguage;
}).catch(function() {
langAlertLink.innerHTML = "This page is available in your language!";
});
}).catch(() => langAlertLink.innerHTML = "This page is available in your language!");
updateLanguageAlert();
break;