Last active
October 19, 2017 17:35
-
-
Save hobelinm/528be93c226663b9f997 to your computer and use it in GitHub Desktop.
Simple language selector to apply language changes to a page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
// Set appropriate language by default | |
if (localStorage.languageSelection) { | |
if(localStorage.languageSelection == "spanish") { | |
$(".spanish").show(); | |
$(".english").hide(); | |
} | |
else { | |
localStorage.languageSelection = "english"; | |
$(".english").show(); | |
$(".spanish").hide(); | |
} | |
} | |
else { | |
// English language by default | |
localStorage.languageSelection = "english"; | |
$(".english").show(); | |
$(".spanish").hide(); | |
} | |
}); | |
function toggleSpanish() { | |
if (localStorage.languageSelection == "spanish") { | |
// Already spanish... | |
return; | |
} | |
// Hide English translation | |
$(".english").toggle(); | |
// Show Spanish translation | |
$(".spanish").toggle(); | |
localStorage.languageSelection = "spanish"; | |
} | |
function toggleEnglish() { | |
if (localStorage.languageSelection == "english") { | |
// Already english... | |
return; | |
} | |
// Hide Spanish translation | |
$(".spanish").toggle(); | |
// Show English translation | |
$(".english").toggle(); | |
localStorage.languageSelection = "english"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can I use this to hide tweets from specific language ?