This plugin is an extension and modification of
JQuery i18n
by Recurser.com which in turn based on
javascript i18n that almost doesn’t suck
by markos.
The enhanced functionality is to easily translate set of HTML elements in a page.
<script type="text/javascript" src="jquery-1.3.1.js"></script> <script type="text/javascript" src="jquery.i18n.js"></script> <script type="text/javascript" src="jquery.i18n.translate.js"></script>
$(document).ready( function() { bahasa_indonesia = { one: "Satu", durian: "Durian", elephant: "Gajah" }; $('#lang_id').click( function() { $.i18n.translate(bahasa_indonesia); }); });
The class should be named so that starts with ‘i18n’, separated with ‘-’, followed by the key name in JS variable.
<div class="i18n-one">One</div> <div class="i18n-durian">Durian</div> <div class="i18n-elephant">Elephant</div> <input type='button' id='lang_id' value='Bahasa Indonesia!' />