0.01
No commit activity in last 3 years
No release in over 3 years
Faker extension providing japanese names
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
>= 0
~> 4.0.0
~> 0.10.1
~> 10.0
~> 3.2.0
~> 3.2.1
~> 0.9.12

Runtime

>= 0
 Project Readme

faker_japanese

Build Status Coverage Status Gem Inline docs

Faker extension to generate Japanese names. Provides fake first and last names in kanji, hiragana, katakana and romaji (name written with latin alphabet). It has now around 1500 last names and around 260 first names for both genders.

Installation

Add this line to your application's Gemfile:

gem 'faker_japanese'

And then execute:

$ bundle

Or install it yourself as:

$ gem install faker_japanese

Usage

To enable faker_japanese manually use

require 'faker/japanese'

Before using, set locale to :ja

Faker::Config.locale = :ja

Then use Faker::Name as you would normally do

n = Faker::Name.name
=> "吉田 順"
ln = Faker::Name.last_name
=> "山本"
fn = Faker::Name.first_name
=> "吉"

Along with name in kanji it is possible to get same values in hiragana, katakana and romaji

n.yomi
=> "よしだ じゅん"
n.kana
=> "ヨシダ ジュン"
n.romaji
=> "Yoshida Jun"

ln.yomi
=> "やまもと"
ln.kana
=> "ヤマモト"
ln.romaji
=> "Yamamoto"

fn.yomi
=> "よし"
fn.kana
=> "ヨシ"
fn.romaji
=> "Yoshi"

When is it useful?

Currently, using default methods provided by Faker it is not possible to reuse localized names and generate from them other fake data.

For example

Faker::Config.locale = "ja"
ln = Faker::Name.last_name
p ln
=> "伊藤"
ml = Faker::Internet.email(ln)
p ml
=>"@.name"

On the other hand, with faker_japanese it is possible to pass name in romaji to generate valid value:

nickname = Faker::Name.name.romaji.split.join.downcase
=> "hayashiyori"
freeemail = Faker::Internet.free_email(nickname)
=> "hayashiyori@gmail.com"

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Acknowledgements

This small piece of code was heavily inspired by the following projects:

License

MIT License (see LICENSE.txt)