Skip to content

Commit 5340c02

Browse files
Fix
1 parent 4e39fe8 commit 5340c02

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

_just/js/lang.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,26 @@ if (localStorage.getItem('Language')) {
4848
}
4949
}
5050

51-
if (window.location.pathname == `${prepathname}/en` && Language === 'en') {
52-
window.location.pathname = window.location.pathname = `${prepathname}/`;
53-
} else if (Language === 'ru' && !window.location.pathname == `${prepathname}/ru`) {
54-
window.location.pathname = `${prepathname}/ru`;
51+
const LangCheck = () => {
52+
if (window.location.pathname == `${prepathname}/en` && Language === 'en') {
53+
window.location.pathname = window.location.pathname = `${prepathname}/`;
54+
} else if (Language === 'ru' && !window.location.pathname == `${prepathname}/ru`) {
55+
window.location.pathname = `${prepathname}/ru`;
56+
}
5557
}
5658

57-
document.getElementById('l-en').addEventListener('click', function() {
58-
Language = 'en';
59-
localStorage.setItem('Language', Language);
60-
});
59+
setTimeout(()=>LangCheck,10)
6160

62-
document.getElementById('l-ru').addEventListener('click', function() {
63-
Language = 'ru';
64-
localStorage.setItem('Language', Language);
65-
});
61+
setTimeout(() => {
62+
document.getElementById('l-en').addEventListener('click', function() {
63+
Language = 'en';
64+
localStorage.setItem('Language', Language);
65+
LangCheck();
66+
});
67+
68+
document.getElementById('l-ru').addEventListener('click', function() {
69+
Language = 'ru';
70+
localStorage.setItem('Language', Language);
71+
LangCheck();
72+
});
73+
}, 100);

0 commit comments

Comments
 (0)