Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function toArabic(text)
- {
- var t = "_" + text.replace(/ /g, "_") + "_";
- t = t.replace(//ig, "e");
- t = t.replace(//ig, "e");
- t = t.replace(//ig, "e");
- t = t.replace(/oo/ig, "w");
- t = t.replace(/ee/ig, "y");
- t = t.replace(/ea/ig, "y");
- t = t.replace(/ie/ig, "y");
- t = t.replace(/ou/ig, "w");
- t = t.replace(/kh/ig, "5");
- t = t.replace(/sh/ig, "H");
- t = t.replace(/ch/ig, "H");
- t = t.replace(/gh/ig, "R");
- t = t.replace(/gu/ig, "k");
- t = t.replace(/gn/ig, "ny");
- t = t.replace(/gn/ig, "ny");
- t = t.replace(/ph/ig, "f");
- t = t.replace(/qu/ig, "k");
- t = t.replace(/tion/ig, "ssywn");
- t = t.replace(/sion/ig, "sywn");
- t = t.replace(/an_/ig, "A_");
- t = t.replace(/in_/ig, "_");
- t = t.replace(/on_/ig, "_");
- t = t.replace(/a_/ig, "A_");
- t = t.replace(/i_/ig, "y_");
- t = t.replace(/o_/ig, "w_");
- t = t.replace(/_x/ig, "_Aks");
- t = t.replace(/_a/ig, "_A");
- t = t.replace(/_e/ig, "_A");
- t = t.replace(/_al/ig, "_Al");
- t = t.replace(/_i/ig, "_A");
- t = t.replace(/_o/ig, "_A");
- t = t.replace(/_l/ig, "_Al");
- t = t.replace(/i/ig, "y");
- t = t.replace(/g/ig, "k");
- t = t.replace(/v/ig, "f");
- t = t.replace(/'/g, "");
- t = t.replace(/e/ig, "-");
- t = t.replace(/i/ig, "-");
- t = t.replace(/a/g, "|");
- t = t.replace(/o/ig, "|");
- var r = "";
- var i = 0;
- var lc = "";
- while (i < t.length)
- {
- var c = t.charAt(i);
- if ("AHORST".indexOf(c) < 0)
- {
- c = c.toLowerCase();
- }
- if (c == lc && c != "l")
- {
- i++;
- continue;
- }
- lc = c;
- if (c == "A") c = "ا"; //alef bela hamza
- // else if (c == "A") c = "أ"; //alef be hameza fo9
- else if (c == "b") c = "ب"; //ba
- else if (c == "c") { if ("-y".indexOf(t.charAt(i + 1)) >= 0) c = "س"; else c = "ك"; }
- else if (c == "d") c = "د"; //dal
- else if (c == "D") c = "ض"; //dad
- // else if (c == "e") c = "ك";
- else if (c == "f") c = "ف";
- // else if (c == "g") c = "ك";
- else if (c == "h") c = "ه";
- else if (c == "H") c = "ش"; //ch
- // else if (c == "i") c = "ئ"; //hamza 3la ya
- // else if (c == "I") c = "إ"; //alef be hamza ta7t
- else if (c == "j") c = "ج";
- else if (c == "k") c = "ك";
- else if (c == "l") c = "ل";
- else if (c == "m") c = "م";
- else if (c == "n") c = "ن";
- else if (c == "O") c = "ٶ"; //hamza 3la waw
- else if (c == "p") c = "پ";
- // else if (c == "q") c = "ك";
- else if (c == "r") c = "ر";
- else if (c == "R") c = "غ"; //gh
- else if (c == "s") { if ("-|ywA".indexOf(t.charAt(i - 1)) >= 0 && "-|ywA".indexOf(t.charAt(i + 1)) >= 0) c = "ز"; else c = "س"; }
- else if (c == "S") c = "ص"; //sad
- else if (c == "t") c = "ت";
- else if (c == "T") c = "ط";
- else if (c == "u") c = "و"; //wa
- // else if (c == "v") c = "ك";
- else if (c == "w") c = "و"; //wa
- else if (c == "x") c = "كس";
- else if (c == "y") c = "ي";
- else if (c == "Y") c = "ى"; //alf m9sora
- else if (c == "z") c = "ز";
- else if (c == "1") c = "ك";
- else if (c == "2") c = "ك";
- else if (c == "3") c = "ع";
- else if (c == "4") c = "ك";
- else if (c == "5") c = "خ";
- else if (c == "6") c = "ط";
- else if (c == "7") c = "ح";
- else if (c == "8") c = "ك";
- else if (c == "9") c = "ق";
- else if (c == "0") c = "ة";
- else if (c == "?") c = "؟";
- r += c;
- i++;
- }
- return r.replace(/\|/g, "").replace(/\-/g, "").replace(/_/g, " ");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement