Created
April 30, 2012 17:56
-
-
Save yurydelendik/2560480 to your computer and use it in GitHub Desktop.
Fake locale translator
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script> | |
var table = "ãь¢Ðε£ģНiʃқḻмпOÞȡг§ţȗṿẂӾӳƩ"; | |
function localize(s) { | |
return s.replace(/(\w+=)([^\n]+)/g, function(all,first,second) { | |
var ar = []; | |
var u = second.replace(/\{\{\w+\}\}/g, function(all) { | |
ar.push(all); | |
return '\u0001'; | |
}); | |
var t = '<<<_'; | |
for (var i = 0; i < u.length; i++) { | |
var ch = u[i]; | |
if (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z') | |
ch = table[(ch.charCodeAt(0) & 31) - 1]; | |
t += ch; | |
} | |
t += '_>>>'; | |
return first + t.replace(/\u0001/, function() { | |
return ar.shift(); | |
}); | |
}); | |
} | |
</script> | |
</head> | |
<body> | |
<textarea id="text"></textarea> | |
<button onclick="document.getElementById('result').value = localize(document.getElementById('text').value)">Convert</button> | |
<textarea id="result"></textarea> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment