Last active
February 14, 2017 18:12
-
-
Save daformat/f978108caec55e3f323203e262ab874e to your computer and use it in GitHub Desktop.
A basic transliteration function
This file contains hidden or 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
/* Basic transliteration helper */ | |
function transliterate(str) { | |
return str.replace(/[ÀÁÂÃÄÅ]/g, 'A') | |
.replace(/[Æ]/g, 'AE') | |
.replace(/[Ç]/g, 'C') | |
.replace(/[ÈÉÊË]/g, 'E') | |
.replace(/[ÌÍÎÏ]/g, 'I') | |
.replace(/[Ñ]/g, 'N') | |
.replace(/[ÒÓÔÕÖ]/g, 'O') | |
.replace(/[Œ]/g, 'OE') | |
.replace(/[ÙÚÛÜ]/g, 'U') | |
.replace(/[ÝŸ]/g, 'Y') | |
.replace(/[àáâãäå]/g, 'a') | |
.replace(/[æ]/g, 'ae') | |
.replace(/[ç]/g, 'c') | |
.replace(/[èéêë]/g, 'e') | |
.replace(/[ìíîï]/g, 'i') | |
.replace(/[ñ]/g, 'n') | |
.replace(/[òóôõö]/g, 'o') | |
.replace(/[œ]/g, 'oe') | |
.replace(/[ùúûü]/g, 'u') | |
.replace(/[ýÿ]/g, 'y'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment