Skip to content
Golang library for conversion between Japanese hiragana, katakana and romaji
Branch: master
Clone or download
Latest commit 3514925 May 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore update travis.yml and gitignore May 2, 2014
.travis.yml Update .travis.yml May 9, 2019
LICENSE add LICENSE file Aug 15, 2016
README.md Update README.md Aug 14, 2016
hiragana.go add che Apr 5, 2015
init.go Auto-initialize and remove need for newKana function Oct 11, 2013
kana.go add "c" to consonants list (fixes #24) Oct 8, 2016
kana_test.go add "c" to consonants list (fixes #24) Oct 8, 2016
katakana.go add che Apr 5, 2015
trie.go remove unused code Jul 21, 2017

README.md

Build Status go report card

kana

A golang library to convert hiragana to romaji, katakana to romaji, romaji to hiragana and romaji to katakana.

Installation

Simply install with go get:

go get github.com/gojp/kana

Usage

To use kana, you'll have to import it:

import "github.com/gojp/kana"
...
k := kana.NewKana()

kana can do many things. It can convert hiragana or katakana to romaji:

s := kana.KanaToRomaji("バナナ") // -> banana
s = kana.KanaToRomaji("かんじ") // -> kanji

It can convert romaji to hiragana or katakana:

s := kana.RomajiToHiragana("kanji") // -> かんじ
s = kana.RomajiToKatakana("banana") // -> バナナ

It can tell you whether strings are written with kana, kanji or latin characters:

kana.IsLatin("banana") // -> true
kana.IsLatin("バナナ") // -> false

kana.IsKana("banana") // -> false
kana.IsKana("バナナ") // -> true

kana.IsKanji("banana") // -> false
kana.IsKanji("減少") // -> true

It can also normalize a given romaji string to a more standardized form (from the form given by Google Translate, for example):

kana.NormalizeRomaji("Myūjikku") // -> myu-jikku
kana.NormalizeRomaji("shitsuree") // -> shitsurei

Please feel free to use, contribute, and enjoy! You can also see this in action at nihongo.io.

Contributors

You can’t perform that action at this time.