Created
January 27, 2015 20:49
-
-
Save josuebrunel/c35345ec07a28d5c7a37 to your computer and use it in GitHub Desktop.
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
## 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