Skip to content

Commit

Permalink
[TASK] change language menu
Browse files Browse the repository at this point in the history
  • Loading branch information
mesosa committed Apr 26, 2024
1 parent c91bddf commit fd7b367
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions theme/js/custom.js
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
// global custom JS
document.addEventListener('DOMContentLoaded', (event) => {
// Select the button text
const buttonText = document.querySelector('.header-language-btn-text')
if (buttonText.textContent === 'SV-SE') {
buttonText.textContent = 'SV'
}
if (buttonText.textContent === 'DA-DK') {
buttonText.textContent = 'DK'
}

// Select the list items
const listItems = document.querySelectorAll('.header-language__list-item-link')
listItems.forEach(item => {
if (item.getAttribute('lang') === 'sv-se') {
item.setAttribute('lang', 'SV')
item.textContent = 'Svenska'
} else if (item.getAttribute('lang') === 'da-dk') {
item.setAttribute('lang', 'DK')
item.textContent = 'Dansk'
}
})
})

0 comments on commit fd7b367

Please sign in to comment.