I complied a script that tells multiple divs through this website http://www.martyregan.com/ to swap from the English div to the Japanese div by clicking the “Website Language” buttons.
It works the way I’d like it, though my client would like to know if it’s possible for the DIVs to stay on the Japanese DIV when going to another page.
The script currently tells the First Child class (of the two corresponding divs) to show and to hide any other sharing that class.
It also tells the first child class to be the active one, so I’d imagine there IS a way to implement some sort of cache/memory script to work with this.
$(function() {
$('#left-sidebar-inner .ddsmoothmenu-v, #right-sidebar-inner .ddsmoothmenu-v, #pb_sidebar .ddsmoothmenu-v, #main-content-inner .content, #main-content-inner .contact, #main-content-inner .right, #main-content-inner .program, #main-content-inner .worksnav, #main-content-inner .worksnav2, #main-content-inner .heading').hide();
$('#left-sidebar-inner .ddsmoothmenu-v:first, #right-sidebar-inner .ddsmoothmenu-v:first, #pb_sidebar .ddsmoothmenu-v:first, #main-content-inner .content:first, #main-content-inner .contact:first, #main-content-inner .right:first, #main-content-inner .program:first, #main-content-inner .worksnav:first, #main-content-inner .worksnav2:first, #main-content-inner .heading:first').show();
$('#language a:first').addClass('active');
$('#language a').click(function() {
if ($(this).hasClass('active') == true) {
return false;
}
else {
$('a.active').removeClass('active');
$(this).addClass('active');
$('#left-sidebar-inner .ddsmoothmenu-v, #right-sidebar-inner .ddsmoothmenu-v, #pb_sidebar .ddsmoothmenu-v, #main-content-inner .content, #main-content-inner .contact, #main-content-inner .right, #main-content-inner .program, #main-content-inner .worksnav, #main-content-inner .worksnav2, #main-content-inner .heading').fadeOut();
var contentToLoad = $(this).attr('href');
$(contentToLoad).fadeIn();
return false;
}
});
});
Here is the example I was given:
$('a.en').click(function(){
localStorage.setItem('language', 'en');
});
$('a.fr').click(function(){
localStorage.setItem('language', 'fr');
});
// to get the language value use getItem
localStorage.getItem('language');
your question can be solved quickly,
so instead of telling you once again that this can be solved by any freelancer
i hope i just did it 😉
this is untested, since it would be pretty too much effort to create the testenvironment,
but it should work, IF you add an html id tag to the links of the language chooser,
notice the id=”en” and the id=’jp’ that i added to the divs.
if thats not possible we will have to add a few more lines.
the script then would be:
have fun
jascha