2.1.0 • Published 7 years ago
romanize-japanese v2.1.0
romanize-japanese
romanize-japanese is a Node.js ES Module port of hepburn package. It's used to convert Hiragana/Katakana to Roman (or vice versa).
visit the original repository for more information about hepburn.
This module also add a beautify parameter to the fromKana hepburn function :
// classic
hepburn.fromKana('きょう') // outputs "KYOU"
// beautified
hepburn.fromKana('きょう', true) // outputs "kyo u"installation
yarn add romanize-japaneseUsage
on a webpage
<script type=module>
import {fromKana} from '/node_modules/romanize-japanese/build/romanize-japanese.mjs'
console.log(fromKana('みみ', true)) // outputs "mi mi"
</script>(note: node_modules needs to be publicly accessible from the client)
in a node es module
import romanize from 'romanize-japanese'
console.log(romanize.fromKana('みみ', true)) // outputs "mi mi"or CommonJS script
console.log(require('romanize-japanese').fromKana('みみ', true))In command line
$ yarn global add romanize-japanese
$ romanize-japanese みみ
mi mi
$Known limitations
This module will only convert hiragana/katakana literals to roman but will not convert any Kanji characters.
Build (browser version)
- clone this repository
yarn installto install the default dependencies (inpackage.json)- (but for instance) if you want to build another version of
hepburnuseyarn add hepburn@<version>
- (but for instance) if you want to build another version of
- then run
yarn build - now
build/romanize-japanese.mjswill contain thehepburnes module for browsers