Created
September 16, 2011 00:47
-
-
Save madpilot/1220907 to your computer and use it in GitHub Desktop.
Client side i18n tranlation demo
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" > | |
<title>i18n Demo</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/madpilot/jquery-i18n/master/jquery.i18n.js"></script> | |
<script type="text/javascript"> | |
var languages = { | |
en: { | |
'heading': 'This is being translated client side', | |
'paragraph': 'This is in English' | |
}, | |
it: { | |
'heading': 'Questo è stato tradotto lato client', | |
'paragraph': 'Questo è in italiano' | |
} | |
}; | |
$(function() { | |
$('#change').change(function(e) { | |
$.i18n.setDictionary(languages[$(this).val()]); | |
$('[data-i18n-key]').each(function(i, e) { | |
$(e)._t($(e).attr('data-i18n-key')) | |
}); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<select id="change"> | |
<option value="en">English</option> | |
<option value="it">Italiano</option> | |
</select> | |
<h1 data-i18n-key="heading">This is being translated client side</h1> | |
<p data-i18n-key="paragraph">This is in English</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment