The Transliterator module provides the ability to transliterate UTF-8 strings into pure ASCII so that they can be safely displayed in URL slugs or file names.
-
Add the dependency to your
shard.yml
:dependencies: cadmium_transliterator: github: cadmiumcr/transliterator
-
Run
shards install
require "cadmium_transliterator"
transliterator = Cadmium.transliterator
transliterator.transliterate("Привет")
# => "Privet"
transliterator.transliterate("你好朋友")
# => "Ni Hao Peng You"
# With the string extension
"މިއަދަކީ ހދ ރީތި ދވހކވ".transliterate
# => "mi'adhakee hdh reethi dhvhkv"
"こんにちは、友人".transliterate
# => konnichiwa, You Ren
- Fork it (https://github.com/cadmiumcr/transliterator/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Chris Watson - creator and maintainer