User:Erutuon/scripts/phonemicGreekTransliteration.js

/*	Modifies Greek transliteration to be more phonemic: voiced stops with dot above, ου as u, all vowels pronounced /i/ as i, no double consonants, diaeresis sometimes removed. The dot above is weird. Greek		default		modified μου			mou			mu οι πολλοί	oi polloí	i polí βοήθεια		voḯtheia	voíthia πολύ		polý		polí είναι		eínai		íne αμπέλι		ámpeli		aḃéli άντρας		ántras		áḋras φεγγάρι		fengári		feġári I'd like to distinguish fricative d from stop d, but at the moment the two aren't distinguished at the beginning of a word! δύο			dýo			(fricative d)	ντετέκτιβ	detéktiv	(stop d)

var dotAbove = String.fromCharCode(0x307);

$("[lang=el-Latn]").html(	function (index, element) {		return element			// At beginning of word, b represents the stop μπ.			.replace(/((?:^|[ -])[Bb])/g, "$1" + dotAbove)			.replace( /([GgNn])[KkGg]/g, function (wholeMatch, firstLetter) { if ( firstLetter.toUpperCase === firstLetter ) { return "G" + dotAbove; } else { return "g" + dotAbove; }				})			.replace( /([Nn])[TtDd](?!h)/g, function (wholeMatch, firstLetter) { if ( firstLetter.toUpperCase === firstLetter ) { return "D" + dotAbove; } else { return "d" + dotAbove; }				})			.replace( /([Mm])[PpBb](?![TtSs])/g, function (wholeMatch, firstLetter) { if ( firstLetter.toUpperCase === firstLetter ) { return "B" + dotAbove; } else { return "b" + dotAbove; }				})			.normalize("NFD")			.replace( /([AaEeOoUu])i(\u0308?)/g, // U+308, combining diaeresis function (wholeMatch, firstLetter, diaeresis) { if (diaeresis !== "") { // If diaeresis is present, remove it. return firstLetter + "i"; }					var capital = firstLetter.toUpperCase === firstLetter; if ( firstLetter === "a" ) { if ( capital ) { return "E"; } else { return "e"; }					} else { if ( capital ) { return "I"; } else { return "i"; }					}				})			.replace(/y/g, "i")			.replace(/Y/g, "I")			.replace(/ou/g, "u")			.replace(/([bgdzklmnprstfv])\1/g, "$1")			.replace(/tz/g, "dz")			.replace(/x/g, "ks")			.normalize("NFC");	});