Skip to content

Instantly share code, notes, and snippets.

@afrael
Created June 1, 2013 16:06
Show Gist options
  • Save afrael/5690869 to your computer and use it in GitHub Desktop.
Save afrael/5690869 to your computer and use it in GitHub Desktop.
Localizable content using Javascript
<a href="#" class="scroller" data-section="#about"><span lang="EN">About</span><span lang="ES">Acerca De</span></a>
<script>
$('.set_lang_EN').click(function(){
$("[lang]").each(function () {
if ($(this).attr("lang") == "EN")
$(this).show();
else
$(this).hide();
});
});
$('.set_lang_ES').click(function(){
$("[lang]").each(function () {
if ($(this).attr("lang") == "ES")
$(this).show();
else
$(this).hide();
});
});
// set default
$("[lang]").each(function () {
if ($(this).attr("lang") == "ES")
$(this).show();
else
$(this).hide();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment