Project

Wanakana

0.0
No commit activity in last 3 years
No release in over 3 years
Change Japanese text to and from romaji, hiragana, and katakana. This gem is a port of WaniKani's JavaScript library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.11
~> 5.8
~> 11.2
 Project Readme

WanaKanaRuby

Ruby port of WaniKani/WanaKana, a Javascript library that provides utilities for detecting and transliterating Hiragana <--> Katakana <--> Romaji.

This port does not have the methods .bind or .unbind for inputs as WanKana.js does.

Installation

Add this line to your application's Gemfile:

gem 'Wanakana'

And then execute:

$ bundle

Or install it yourself as:

$ gem install Wanakana

Usage

# Returns false if string contains mixed characters, otherwise true if Hiragana.
Wanakana.is_hiragana?(string)

# Returns false if string contains characters outside of the kana family, otherwise true if Hiragana and/or Katakana.
Wanakana.is_kana?(string)

# Returns false if string contains mixed characters, otherwise true if Katakana.
Wanakana.is_katakana>(string)

# Convert Katakana or Romaji to Hiragana.
Wanakana.to_hiragana(string [, options])

# Convert Romaji to Kana. Lowcase entries output Hiragana, while upcase entries output Katakana.
Wanakana.to_kana(string [, options])

# Convert Hiragana or Romaji to Katakana.
Wanakana.to_katakana(string [, options])

# Convert Kana to Romaji.
Wanakana.to_romaji(string [, options])

# Options:
# Many functions take an optional `options` hash.
# Here is the default hash used for options.
{
	:useObsoleteKana => false, # Set to true to use obsolete characters, such as ゐ and ゑ.
	:convertKatakanaToUppercase => false # Set to true to convert katakana characters to uppercase romaji.
}

Development

After cloning the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The gem is available as open source under the terms of the MIT License.