Skip to content

Instantly share code, notes, and snippets.

@ETBlue
Created February 1, 2011 07:16
Show Gist options
  • Save ETBlue/805535 to your computer and use it in GitHub Desktop.
Save ETBlue/805535 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
var csvFile=new XMLHttpRequest();
var filePath="file:///home/etblue/Codes/translation/rails-guide-glossary-list-zh_tw.csv"
csvFile.open("GET", filePath, false);
csvFile.send();
glossary = csvFile.responseText.split("\n");
for(var i=0;i<glossary.length;i++)
{
words=glossary[i].split(",");
var en=" "+words[1]+" ";
var zh=words[2];
var suggest=words[3];
var pattern=new RegExp(en,'g');
document.body.innerHTML = document.body.innerHTML.replace(pattern,'<B style="color:red;">'+en+'<small style="color:green;">中譯:'+zh+',翻譯方式:'+suggest+'</small></B> ');
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment