Search code examples
javascriptmultilingual

How convert é -> e, š -> s, ė -> e , ą -> a ... in javascript?


I have a string like Brazil: Série A my goal is to convert to Brazil: Serie A.

Also, method should convert and other similar situations: é -> e, š -> s, ė -> e , ą -> a ...


Solution

  • I'm using Slugify (https://github.com/simov/slugify) to do just that. It comes with a predefined set of characters it will replace with plain english ones https://github.com/simov/slugify/blob/master/index.js#L13 and the ability to extend it.