Skip to content

Instantly share code, notes, and snippets.

@josuebrunel
Created January 27, 2015 20:49
Show Gist options
  • Save josuebrunel/c35345ec07a28d5c7a37 to your computer and use it in GitHub Desktop.
Save josuebrunel/c35345ec07a28d5c7a37 to your computer and use it in GitHub Desktop.
## A simple translation engine in jquery
## translation.json looks like
{
"your_id" : "text value to translate to"
}
/*
Translation hanlder
*/
$("#fr, #en, #chi, #por, #ger, #spa").click(function(){
var self = $(this);
var id = self.attr('id');
var path = '_locales/'+id+'/translation.json'
json_data = $.getJSON(path, function(data){
$.each(data, function(key, val){
$('#'+key).text(val);
})
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment