Answer the question
In order to leave comments, you need to log in
How can I do language switching in PhoneGap/Cordova?
Good evening.
How can I switch the language?
As far as I understand, this won’t work through a regular cookie, it’s necessary through localStorage.
I’m trying to make it so that when the desired radio is selected, it redirects to the index-ru.html page, or if the language is eng, it redirects to the index-end.html page And so that when you re- when you enter the page, the active value is taken from the cookie and redirected to the desired page itself.
Can you suggest how this can be done?
Answer the question
In order to leave comments, you need to log in
<p>
<label><input type="radio" name="set-lang" value="RU" /> RU</label>
<label><input type="radio" name="set-lang" value="EN" /> EN</label>
</p>
<script>
function langRoute(){
if (localStorage.getItem('lang')=='RU' ) window.location.href = 'index-ru.html';
if (localStorage.getItem('lang')=='EN' ) window.location.href = 'index-en.html';
}
$(document)
.on('change','input[name="set-lang"]',function(){
localStorage.setItem('lang',$(this).attr('value'));
langRoute();
})
.ready(function(){
langRoute(); //Если нужно запомнить выбор пользователя
})
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question