Exromaji
A Elixir library for converting between hiragana, katakana, and romaji.
Installation
If available in Hex, the package can be installed as:
- Add exromaji to your list of dependencies in
mix.exs:
def deps do
[{:exromaji, "~> 0.2"}]
end
- Ensure exromaji is started before your application:
def application do
[applications: [:exromaji]]
end
- Exromaji package needs
nkfcommand and it needs to install that in your environment when you don't havenkf.
$ brew install nkf
Usage
Exromaji provides some convinient functions in Exromaji module through Exromaji.Translator and Exromaji.Table. Those provided functions are able to translate into hiragana(ひらがな), katakana(カタカナ) and Romaji(ローマ字).
Into hiragana(ひらがな)
iex(1)> Exromaji.hiragana "a a A ア ア ァ ァ あ ぁ 亜"
"あ あ あ あ あ ぁ ぁ あ ぁ 亜"
iex(2)> Exromaji.hiragana "ヒラガナ hiragana"
"ひらがな ひらがな"
Into katakana(カタカナ)
iex(3)> Exromaji.katakana "a a A ア ア ァ ァ あ ぁ 亜"
"ア ア ア ア ア ァ ァ ア ァ 亜"
iex(4)> Exromaji.katakana "かたかな katakana"
"カタカナ カタカナ"
Into Romaji(ローマ字)
iex(5)> Exromaji.romaji "a a A ア ア ァ ァ あ ぁ 亜"
"a a a a a ァ ァ a ァ 亜"
iex(6)> Exromaji.romaji "ローマジ ろーまじ"
"ro-maji ro-maji"