kana_kit 1.0.0 kana_kit: ^1.0.0 copied to clipboard
A Dart library for handling and converting Japanese characters such as hiragana, katakana and kanji.
KanaKit #
A Dart library for for detecting and transliterating Hiragana, Katakana, and Romaji.
This library is mostly a direct port of WaniKani's WanaKana JavaScript library.
Usage #
To use KanaKit, construct a KanaKit
class instance.
It contains all available methods for detecting and converting Japanese text.
// Create a KanaKit instance.
// If no config is provided, KanaKitConfig.defaultConfig is used.
const kanaKit = KanaKit();
// String checks
kanaKit.isJapanese('泣き虫。!〜2¥zenkaku') // true
kanaKit.isKana('あーア') // true
kanaKit.isHiragana('すげー') // true
kanaKit.isKatakana('ゲーム') // true
kanaKit.isKanji('切腹') // true
kanaKit.isKanji('勢い') // false
kanaKit.isRomaji('Tōkyō and Ōsaka') // true
// String converters
kanaKit.toKana('ONAJI buttsuuji') // 'オナジ ぶっつうじ'
kanaKit.toKana('座禅‘zazen’スタイル') // '座禅「ざぜん」スタイル'
kanaKit.toKana('batsuge-mu') // 'ばつげーむ'
kanaKit.toHiragana('toukyou, オオサカ') // 'とうきょう、 おおさか'
kanaKit.toKatakana('toukyou, おおさか') // 'トウキョウ、 オオサカ'
kanaKit.toRomaji('ひらがな カタカナ') // 'hiragana katakana'
// Use upcaseKatakana to
final kanaKitWithUpcaseKatakana = kanaKit(
upcaseKatakana: true,
);
kanaKitWithUpcaseKatakana.toRomaji('ひらがな カタカナ') // 'hiragana KATAKANA'