i can’t find solution for this bug i wrok on site web multi language but i can’t don’t know how to fix this bug
JavaScript
x
23
23
1
class translate{
2
constructor(){
3
4
document.getElementById("fr").addEventListener('click', ()=>{
5
this.translate("fr");
6
});
7
document.getElementById("en").addEventListener('click', ()=>{
8
this.translate("en");
9
});
10
this.translate(localStorage.getItem("language"));
11
}
12
translate(language){
13
if(language == "fr"){
14
document.getElementById("myAnchor").href = "http://www.cnn.com/";
15
}
16
else if (language =="en"){
17
document.getElementById("myAnchor").href = "http://www.google.com/";
18
}
19
localStorage.setItem("language",language);
20
}
21
}
22
onload = new translate();
23
code Html and link i need to change
JavaScript
1
14
14
1
<div class="contenu-space-two">
2
<div class="row mx-0">
3
<div class=" col-2">
4
<img src="./resources/_images/shopping-cart.png" class="logo-link" alt="">
5
</div>
6
<div class="col-lg-4 col-md-6 col-8" >
7
<h4 class="lang" key="boutiques">Boutiques</h4>
8
</div>
9
<div class="col-2">
10
<a id="myAnchor" href="#"><img src="./resources/_images/arrow-link.png" class="arrow-link" alt=""></a>
11
</div>
12
<hr class="line_link">
13
</div>
14
and this code language
JavaScript
1
5
1
<div id="langContainer">
2
<a class="translate" id="lang_link[en]" href="#" style="display:none"><img src="./resources/_images/flags/en.png?1595436503" title="English"></a>
3
<a class="translate" id="lang_link[fr]" href="#" style="display:none"><img src="./resources/_images/flags/fr.png?1595436503" title="Français"></a>
4
</div>
5
Advertisement
Answer
This variable has probably already been declared. Check this js file and the others the page references.
If there are many you can try to change the name of this class.