Skip to content

Commit

Permalink
feat: add language support to test page
Browse files Browse the repository at this point in the history
  • Loading branch information
sirtawast committed Sep 4, 2024
1 parent 841196a commit 975aef2
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// Simulate Drupal environment
var drupalSettings = {};
drupalSettings.path = {};
drupalSettings.path.currentLanguage = 'fi';
drupalSettings.path.currentLanguage = window.sessionStorage.getItem('testLang') || 'fi'
console.log(drupalSettings.path);

drupalSettings.helsinki_benefit_amount_estimate = `
{
Expand All @@ -36,6 +37,22 @@
<div class="paragraph-content components components--upper">
<div class="component component--helfi-calculator">
<div class="component__container">
<header>
<a class="lang-select" href="?lang=fi">Fi</a>
<a class="lang-select" href="?lang=sv">Sv</a>
<a class="lang-select" href="?lang=en">En</a>
<script>
var langClick = (e) => {
e.preventDefault();
console.log(e)
window.sessionStorage.setItem('testLang', e.target.href.split('?lang=')[1]);
window.location.reload(true);
}
document.querySelectorAll('.lang-select').forEach((element) =>
element.addEventListener("click", langClick));
</script>
<hr>
</header>
<h2 class="component__title">Laske arvio Helsinki-lisästä</h2>
<div class="component__content helfi-calculator">
<div id="helfi_calc_1234567890"></div>
Expand Down

0 comments on commit 975aef2

Please sign in to comment.