Skip to content

Instantly share code, notes, and snippets.

@daformat
Last active February 14, 2017 18:12
Show Gist options
  • Save daformat/f978108caec55e3f323203e262ab874e to your computer and use it in GitHub Desktop.
Save daformat/f978108caec55e3f323203e262ab874e to your computer and use it in GitHub Desktop.
A basic transliteration function
/* 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