Last active
August 29, 2015 14:04
-
-
Save RobertCalise/088076be6db100491ac2 to your computer and use it in GitHub Desktop.
Simple text replacement with jQuery.
This file contains hidden or 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> | |
<title>jQuery Translation Example</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
var translate = { | |
"Hello, world!": "Bonjour tout le monde!", | |
"This is an example.": "Ceci est un exemple." | |
}; | |
$.each(translate, function(key, value) { | |
$('body').html($('body').html().replace(key, value)); | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<h1>Example</h1> | |
<p>Hello, world!</p> | |
<p>This is an example.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment