A Elixir library for translating between hiragana, katakana, romaji and sound.
If available in Hex, the package can be installed as:
- Add exromaji to your list of dependencies in
mix.exs
:
def deps do
[{:exromaji, "~> x.x"}]
end
- Exromaji package needs
nkf
command and it needs to install that in your environment when you don't havenkf
.
$ brew install nkf
Exromaji provides some convinient functions in Exromaji module through Exromaji.Translator and Exromaji.Table. Those provided functions are able to translate into hiragana(ひらがな), katakana(カタカナ), romaji(ローマ字) and sound(五十音).
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"
Into sound(五十音)
iex(7)> Exromaji.sound "よろしく"
"や"
Those provided functions cannot detect Kanji(漢字) in translation working, like this.
iex(9)> Exromaji.romaji "ローマ字"
"ro-ma字"
iex(10)> Exromaji.sound "夜露死苦"
nil
However exkanji package are detecting Kanji(漢字). It also inspires a imitational interfaces from exromaji. I suppose that you'll install exkanji package in your development as required.
iex(11)> Exkanji.romaji "ローマ字"
"ro-maji"
iex(12)> Exkanji.sound "夜露死苦"
"や"