Sithdown / WanaKana

Javascript library for detecting and transliterating Hiragana <--> Katakana <--> Romaji

Home Page:http://wanakana.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ワナカナ <-> WanaKana <-> わなかな

Javascript library that provides utilities for detecting and transliterating Hiragana <--> Katakana <--> Romaji.

View demo site to see WanaKana in action.

Build using Grunt

  • Clone repository.
  • Install all dependencies from package.json using npm install.
  • Run grunt.
    • General development grunt default or just grunt
    • Open test suite (Mac only) grunt test
    • Deploy grunt deploy
    • Demo grunt demo - runs a deploy then copies html and opens a browser window
    • Full list of tasks grunt --help

Usage

HTML

<textarea id="ime"></textarea>

Javascript

var input = document.getElementById('ime');
wanakana.bind(input);

Documentation

// Automatically bind IME functionality to a form textarea or input.
wanakana.bind(element);

// Unbind IME from element.
wanakana.unbind(element);

// Returns false if string contains mixed characters, otherwise true if Hiragana.
wanakana.isHiragana(string);

// Returns false if string contains characters outside of the kana family, otherwise true if Hiragana and/or Katakana.
wanakana.isKana(string);

// Returns false if string contains mixed characters, otherwise true if Katakana.
wanakana.isKatakana(string);

// Convert Katakana or Romaji to Hiragana.
wanakana.toHiragana(string [, options]);

// Convert Romaji to Kana. Lowcase entries output Hiragana, while upcase entries output Katakana.
wanakana.toKana(string [, options]);

// Convert Hiragana or Romaji to Katakana.
wanakana.toKatakana(string [, options]);

// Convert Kana to Romaji.
wanakana.toRomaji(string [, options]);

// Options:
// Many functions take an optional `options` object.
// Here is the default object used for options.
{
	useObsoleteKana: false, // Set to true to use obsolete characters, such as ゐ and ゑ.
  	IMEMode: false // Set to true to handle input from a text input as it is typed.
}

Credits

Project sponsored by Tofugu & WaniKani

Contributors

Ports

The following are ports created by the community:

About

Javascript library for detecting and transliterating Hiragana <--> Katakana <--> Romaji

http://wanakana.com

License:MIT License


Languages

Language:JavaScript 66.1%Language:CoffeeScript 27.6%Language:HTML 6.3%