This HTML script transliterates every word, phrase or letter entered into it.
Essentially, it is an unofficial translator.
When testing the code using jsFiddle, I'm presented with the following error:
{"error": "Please use POST request"}
I saved my file properly as .html, and opened it with Google Chrome.
Everything works as such; I'm able to transliterate text, but the moment I put too much text to be transliterated, the text within the boxes is omitted and the code (page) essentially 'refreshes' itself.
This code does translate small phrases and words, however.
Is there a limit to the amount of characters to be transliterated?
I'm not sure what the error is indicating, but I'm sure the aforementioned jsFiddle error corresponds with this one.
It's puzzling me.
The transliteration code is as followed:
<html>
<head>
<title>English - Imzreth Translator</title>
<script>
validator = "aábcdeéfghjiíklmnoöpqrstuüvwxyzAÁBCDEÉFGHIJKLMNOÖPQRSTUÜVWXYZ’";
vowels = "aáeéiíoöuüyAÁEÉIÍOÖUÜY’";
aemap = new Array();
aemap["au"] = "a";
aemap["a"] = "a";
aemap["l"] = "b";
aemap["b"] = "b";
aemap["c"] = "c";
aemap["ku"] = "d";
aemap["d"] = "d";
aemap["u"] = "e";
aemap["u"] = "e";
aemap["f"] = "f";
aemap["gé"] = "g";
aemap["g"] = "g";
aemap["h"] = "h";
aemap["o"] = "i";
aemap["i"] = "i";
aemap["t"] = "j";
aemap["j"] = "j";
aemap["ré"] = "k";
aemap["k"] = "k";
aemap["l"] = "l";
aemap["m"] = "m";
aemap["q"] = "n";
aemap["n"] = "n";
aemap["i"] = "o";
aemap["o"] = "o";
aemap["ph"] = "p";
aemap["p"] = "p";
aemap["q"] = "q";
aemap["r"] = "r";
aemap["s"] = "s";
aemap["s"] = "t";
aemap["t"] = "t";
aemap["e"] = "u";
aemap["u"] = "u";
aemap["z"] = "v";
aemap["v"] = "v";
aemap["w"] = "w";
aemap["l"] = "x";
aemap["x"] = "x";
aemap["y"] = "y";
aemap["á"] = "y";
aemap["z"] = "z";
eamap = new Array();
eamap["a"] = "au";
eamap["b"] = "l";
eamap["c"] = "c";
eamap["d"] = "ku";
eamap["e"] = "u";
eamap["f"] = "f";
eamap["g"] = "gé";
eamap["h"] = "h";
eamap["i"] = "o";
eamap["j"] = "t";
eamap["k"] = "ré";
eamap["l"] = "l";
eamap["m"] = "m";
eamap["n"] = "n";
eamap["o"] = "i";
eamap["p"] = "ph";
eamap["q"] = "q";
eamap["r"] = "r";
eamap["s"] = "s";
eamap["t"] = "s";
eamap["u"] = "e";
eamap["v"] = "z";
eamap["w"] = "w";
eamap["x"] = "l";
eamap["y"] = "á";
eamap["z"] = "z";
eamap["A"] = "A";
eamap["B"] = "B";
eamap["C"] = "C";
eamap["D"] = "D";
eamap["E"] = "E";
eamap["F"] = "F";
eamap["G"] = "G";
eamap["H"] = "H";
eamap["I"] = "I";
eamap["J"] = "J";
eamap["K"] = "K";
eamap["L"] = "L";
eamap["M"] = "M";
eamap["N"] = "N";
eamap["O"] = "O";
eamap["P"] = "P";
eamap["Q"] = "Q";
eamap["R"] = "R";
eamap["S"] = "S";
eamap["T"] = "T";
eamap["U"] = "U";
eamap["V"] = "V";
eamap["W"] = "W";
eamap["X"] = "X";
eamap["Y"] = "Y";
eamap["Z"] = "Z";
promap = new Array();
promap["a"] = "aah";
promap["b"] = "buh";
promap["c"] = "se";
promap["d"] = "duh";
promap["e"] = "eh";
promap["f"] = "f";
promap["g"] = "guh";
promap["h"] = "h’";
promap["i"] = "íh";
promap["j"] = "juh";
promap["k"] = "kuh";
promap["l"] = "l’";
promap["m"] = "m";
promap["n"] = "n";
promap["o"] = "öh";
promap["p"] = "puh";
promap["q"] = "quah";
promap["r"] = "ra";
promap["s"] = "s";
promap["t"] = "t’uh";
promap["u"] = "ooh";
promap["v"] = "vuh";
promap["w"] = "wuh";
promap["x"] = "k’ss";
promap["y"] = "ya";
promap["z"] = "z";
promap["ph"] = "f’";
promap["au"] = "aw";
promap["gé"] = "zhé";
promap["á"] = "ahh";
promap["ku"] = "kü";
promap["A"] = "Á";
promap["B"] = "B’";
promap["C"] = "CÉ";
promap["D"] = "D’";
promap["E"] = "EH";
promap["F"] = "F’";
promap["G"] = "G’";
promap["H"] = "H’";
promap["I"] = "Í’";
promap["J"] = "J’";
promap["K"] = "K’";
promap["L"] = "L’";
promap["M"] = "M";
promap["N"] = "N";
promap["O"] = "Ö’";
promap["P"] = "P’";
promap["Q"] = "Q’";
promap["R"] = "RA";
promap["S"] = "SEE";
promap["T"] = "T’UH";
promap["U"] = "OOH";
promap["V"] = "VUH";
promap["W"] = "WUH";
promap["X"] = "K’SS";
promap["Y"] = "YA";
promap["Z"] = "Z";
promap["PH"] = "F";
promap["AU"] = "AW";
promap["KU"] = "KÜ";
function transme() {
if (document.theform.picker[0].checked) { // english to al bhed
builder = "";
toggler = 0;
for (var i = 0; i < document.theform.stimulus.value.length; i++) {
if (document.theform.stimulus.value.charAt(i) == "[") {
toggler = 1;
};
if (document.theform.stimulus.value.charAt(i) == "]") {
toggler = 0;
};
if (toggler == 1) {
builder = builder + document.theform.stimulus.value.charAt(i);
} else {
if (validator.indexOf(document.theform.stimulus.value.charAt(i)) == -1) {
builder = builder + document.theform.stimulus.value.charAt(i);
} else {
builder = builder + eamap[document.theform.stimulus.value.charAt(i)];
};
};
};
builder2 = "";
toggler = 0;
prev = 0;
for (var i = 0; i < document.theform.stimulus.value.length; i++) {
if (document.theform.stimulus.value.charAt(i) == "[") {
toggler = 1;
};
if (document.theform.stimulus.value.charAt(i) == "]") {
toggler = 0;
};
if (toggler == 1) {
builder2 = builder2 + document.theform.stimulus.value.charAt(i);
} else {
if (validator.indexOf(document.theform.stimulus.value.charAt(i)) == -1) {
builder2 = builder2 + document.theform.stimulus.value.charAt(i);
prev = 0;
} else {
temp = promap[eamap[document.theform.stimulus.value.charAt(i)]];
if (prev == 1) {
if ((vowels.indexOf(temp.charAt(0)) == -1) && (temp.length != 1)) {
builder2 = builder2 + "-";
};
};
builder2 = builder2 + temp;
prev = 1;
};
};
};
document.theform.response.value = builder + "\n\nPronounced: \"" + builder2 + "\"";
} else { //al bhed to english
builder = "";
toggler = 0;
for (var i = 0; i < document.theform.stimulus.value.length; i++) {
if (document.theform.stimulus.value.charAt(i) == "[") {
toggler = 1;
};
if (document.theform.stimulus.value.charAt(i) == "]") {
toggler = 0;
};
if (toggler == 1) {
builder = builder + document.theform.stimulus.value.charAt(i);
} else {
if (validator.indexOf(document.theform.stimulus.value.charAt(i)) == -1) {
builder = builder + document.theform.stimulus.value.charAt(i);
} else {
builder = builder + aemap[document.theform.stimulus.value.charAt(i)];
};
};
};
document.theform.response.value = builder;
};
return false;
};
</script>
</head>
<body>
<form method="get" name="theform" action="" onSubmit="return transme()">
<p><b><h2>English to Custom Language Translator (With Phonetics)</h2></b>
<p><b>Translate Text:</b>
<br> <u>(Excluded text should be within brackets).</u>
<br>
<textarea name="stimulus" cols="60" rows="6" wrap="VIRTUAL"></textarea>
</p>
<p><b>Translated Text:</b>
<br>
<textarea name="response" cols="60" rows="6" wrap="VIRTUAL"></textarea>
</p>
<p><b>Translation Options:</b>
<br>
<input name="picker" type="radio" value="0" checked>English to Custom Language (With Phonetics)
<br>
<input name="picker" type="radio" value="1">Custom Language to English (With Rough Phonetics)</p>
<p>
<input type="submit" value="Transl ate / Traunslausu!">
</p>
</form>
</body>
</html>
I would gladly appreciate help in fixing the code to ensure full functionality.