ワナカナ <--> WanaKana <--> わなかな
Javascript utility library for detecting and transliterating Hiragana, Katakana, and Romaji
Demo
Visit the website to see WanaKana in action.
Usage
In the browser without a build step, use the minified (UMD) bundle (with browser polyfills)
https://unpkg.com/wanakana
<head>
<meta charset="UTF-8">
<script src="https://unpkg.com/wanakana"></script>
</head>
<body>
<input type="text" id="wanakana-input" />
<script>
var textInput = document.getElementById('wanakana-input');
wanakana.bind(textInput, );
</script>
</body>
ES Modules or Node
Install
npm install wanakana
ES Modules
import * as wanakana from 'wanakana';
import { toKana, isRomaji } from 'wanakana';
Node (>=12 supported)
const wanakana = require('wanakana');
Documentation
Extended API reference
Quick Reference
wanakana.bind(domElement [, options]);
wanakana.unbind(domElement);
wanakana.isJapanese('泣き虫。!〜2¥zenkaku')
wanakana.isKana('あーア')
wanakana.isHiragana('すげー')
wanakana.isKatakana('ゲーム')
wanakana.isKanji('切腹')
wanakana.isKanji('勢い')
wanakana.isRomaji('Tōkyō and Ōsaka')
wanakana.toKana('ONAJI buttsuuji')
wanakana.toKana('座禅‘zazen’スタイル')
wanakana.toKana('batsuge-mu')
wanakana.toKana('wanakana', { customKanaMapping: { na: 'に', ka: 'bana' }) });
wanakana.toHiragana('toukyou, オオサカ')
wanakana.toHiragana('only カナ', { passRomaji: true })
wanakana.toHiragana('wi', { useObsoleteKana: true })
wanakana.toKatakana('toukyou, おおさか')
wanakana.toKatakana('only かな', { passRomaji: true })
wanakana.toKatakana('wi', { useObsoleteKana: true })
wanakana.toRomaji('ひらがな カタカナ')
wanakana.toRomaji('ひらがな カタカナ', { upcaseKatakana: true })
wanakana.toRomaji('つじぎり', { customRomajiMapping: { じ: 'zi', つ: 'tu', り: 'li' }) };
wanakana.stripOkurigana('お祝い')
wanakana.stripOkurigana('踏み込む')
wanakana.stripOkurigana('お腹', { leading: true });
wanakana.stripOkurigana('ふみこむ', { matchKanji: '踏み込む' });
wanakana.stripOkurigana('おみまい', { matchKanji: 'お祝い', leading: true });
wanakana.tokenize('ふふフフ')
wanakana.tokenize('hello 田中さん')
wanakana.tokenize('I said 私はすごく悲しい', { compact: true })
Important
Only the browser build via unpkg or the root wanakana.min.js
includes polyfills for older browsers.
Contributing
Please see CONTRIBUTING.md
Contributors
Credits
Project sponsored by Tofugu & WaniKani
Ports
The following ports have been created by the community: