Skip to main content

jskana

Project Javascript Library
Table of Contents

Javascript library for Japanese kana and romaji conversion.

EClaesson/jskana

Japanese kana and romaji conversion.

JavaScript
2
0

https://www.npmjs.com/package/jskana

Installation
#

npm install jskana --save

Documentation
#

Writing system checks
#

isHiragana(str, include_punctuation)

Returns true if all characters in str is hiragana or whitespace.

If include_punctuation is true, punctuation characters will also be accepted.

isKatakana(str, include_punctuation)

Returns true if all characters in str is katakana or whitespace.

If include_punctuation is true, punctuation characters will also be accepted.

isKanji(str, include_punctuation)

Returns true if all characters in str is kanji or whitespace.

If include_punctuation is true, punctuation characters will also be accepted.

isRomaji(str, include_punctuation)

Returns true if all characters in str is romaji or whitespace.

If include_punctuation is true, punctuation characters will also be accepted.

isPunctuation(str)

Returns true if all characters in str is punctuation or whitespace.

String split
#

splitKanaString(str)

Splits a hiragana or katakana string into separate characters, grouped with small characters.

Example: ‘あっさり’ will return [‘あ’, ‘っさ’, ‘り’].

Kana conversion
#

hiraganaToKatakana(str)

Return a string based on str where all hiragana characters are replaced with katakana.

katakanaToHiragana(str)

Return a string based on str where all katakana characters are replaced with hiragana.

kanaToRomaji(str)

Returns a string based on str where all hiragana and katakana are replaced with romaji.

romajiToHiragana(str)

Returns a string based on str with all romaji replaced with hiragana.

romajiToKatakana(str)

Returns a string based on str with all romaji replaced with katakana.

Examples
#

const jskana = require('jskana');

jskana.isHiragana('かに さん。 にぎりめし より')
> true

jskana.isKatakana('アメリカ XYZ')
> false

jskana.isKanji('日一大年中')
> true

jskana.isPunctuation('『モー人本あっ』')
> false

jskana.splitKanaString('あっさり')
> ['あ', 'っさ', 'り']

jskana.hiraganaToKatakana('「うまい もも こっちゃ こい。 にがい もも あっちゃ いけ。」 と いったら、 ')
> '「ウマイ モモ コッチャ コイ。 ニガイ モモ アッチャ イケ。」 ト イッタラ、 '

jskana.kanaToRomaji('こちゃに れもんを いれます。')
> 'kochani remonwo iremasu。'

jskana.romajiToHiragana('kochani remonwo iremasu')
> 'こちゃに れもんを いれます'