Skip to content

Commit

Permalink
refactor: added code for displaying current lanuage in header
Browse files Browse the repository at this point in the history
  • Loading branch information
moiz-deriv committed Oct 18, 2024
1 parent 948915a commit 01a6b27
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/js/footer/displayCurrentLang/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
document.addEventListener("DOMContentLoaded", function () {
let currentLocaleElement = document.querySelector(
".locale > .new-navbar_dropdown-link.w--current"
);
if (currentLocaleElement) {
let currentLocaleIsoCode = currentLocaleElement.getAttribute("hreflang");
let currentLocaleIsoCodeTexts = document.querySelectorAll(
".current-locale-iso-code"
);
if (currentLocaleIsoCode && currentLocaleIsoCodeTexts.length) {
for (let currentLocaleIsoCodeText of currentLocaleIsoCodeTexts) {
currentLocaleIsoCodeText.innerText = currentLocaleIsoCode;
}
}
}
});

0 comments on commit 01a6b27

Please sign in to comment.