Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Preslovljavanje LATINICE <=> Ћирилицу
Object.defineProperty(String.prototype,'lat2cir',{get:function(){return this.toString().replace(/A/g,"А").replace(/B/g,"Б").replace(/V/g,"В").replace(/G/g,"Г").replace(/DŽ/g,"Џ").replace(/Dž/g,"Џ").replace(/Đ/g,"Ђ").replace(/DJ/g,"Ђ").replace(/Dj/g,"Ђ").replace(/D/g,"Д").replace(/E/g,"Е").replace(/Ž/g,"Ж").replace(/Z/g,"З").replace(/I/g,"И").replace(/K/g,"К").replace(/LJ/g,"Љ").replace(/Lj/g,"Љ").replace(/L/g,"Л").replace(/M/g,"М").replace(/NJ/g,"Њ").replace(/Nj/g,"Њ").replace(/J/g,"Ј").replace(/N/g,"Н").replace(/O/g,"О").replace(/P/g,"П").replace(/R/g,"Р").replace(/S/g,"С").replace(/T/g,"Т").replace(/Ć/g,"Ћ").replace(/U/g,"У").replace(/F/g,"Ф").replace(/H/g,"Х").replace(/C/g,"Ц").replace(/Č/g,"Ч").replace(/Š/g,"Ш").replace(/a/g,"а").replace(/b/g,"б").replace(/v/g,"в").replace(/g/g,"г").replace(/dž/g,"џ").replace(/đ/g,"ђ").replace(/dj/g,"ђ").replace(/d/g,"д").replace(/e/g,"е").replace(/ž/g,"ж").replace(/z/g,"з").replace(/i/g,"и").replace(/k/g,"к").replace(/lj/g,"љ").replace(/l/g,"л").replace(/m/g,"м").replace(/nj/g,"њ").replace(/j/g,"ј").replace(/n/g,"н").replace(/o/g,"о").replace(/p/g,"п").replace(/r/g,"р").replace(/s/g,"с").replace(/t/g,"т").replace(/ć/g,"ћ").replace(/u/g,"у").replace(/f/g,"ф").replace(/h/g,"х").replace(/c/g,"ц").replace(/č/g,"ч").replace(/š/g,"ш")}});
Object.defineProperty(String.prototype,'cir2lat',{get:function(){return this.toString().replace(/А/g,"A").replace(/Б/g,"B").replace(/В/g,"V").replace(/Г/g,"G").replace(/Џ/g,"DŽ").replace(/Џ/g,"Dž").replace(/Ђ/g,"Đ").replace(/Ђ/g,"DJ").replace(/Ђ/g,"Dj").replace(/Д/g,"D").replace(/Е/g,"E").replace(/Ж/g,"Ž").replace(/З/g,"Z").replace(/И/g,"I").replace(/К/g,"K").replace(/Љ/g,"LJ").replace(/Љ/g,"Lj").replace(/Л/g,"L").replace(/М/g,"M").replace(/Њ/g,"NJ").replace(/Њ/g,"Nj").replace(/Ј/g,"J").replace(/Н/g,"N").replace(/О/g,"O").replace(/П/g,"P").replace(/Р/g,"R").replace(/С/g,"S").replace(/Т/g,"T").replace(/Ћ/g,"Ć").replace(/У/g,"U").replace(/Ф/g,"F").replace(/Х/g,"H").replace(/Ц/g,"C").replace(/Ч/g,"Č").replace(/Ш/g,"Š").replace(/а/g,"a").replace(/б/g,"b").replace(/в/g,"v").replace(/г/g,"g").replace(/џ/g,"dž").replace(/ђ/g,"đ").replace(/ђ/g,"dj").replace(/д/g,"d").replace(/е/g,"e").replace(/ж/g,"ž").replace(/з/g,"z").replace(/и/g,"i").replace(/к/g,"k").replace(/љ/g,"lj").replace(/л/g,"l").replace(/м/g,"m").replace(/њ/g,"nj").replace(/ј/g,"j").replace(/н/g,"n").replace(/о/g,"o").replace(/п/g,"p").replace(/р/g,"r").replace(/с/g,"s").replace(/т/g,"t").replace(/ћ/g,"ć").replace(/у/g,"u").replace(/ф/g,"f").replace(/х/g,"h").replace(/ц/g,"c").replace(/ч/g,"č").replace(/ш/g,"š")}});
//primer
var tekstCir="Đurđevak je cvet".lat2cir; // "Ђурђевак је цвет"
var tekstLat=tekstCir.cir2lat; // "Đurđevak je cvet"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment