Skip to content
/ kana Public

Golang library for conversion between Japanese hiragana, katakana and romaji

License

Notifications You must be signed in to change notification settings

gojp/kana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status go report card GoDoc

kana

Golang library for convertiong 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

Convert hiragana or katakana to romaji:

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

Convert romaji to hiragana or katakana:

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

Tell 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

Normalize a romaji string to a 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.