Skip to content
Zach Leigh edited this page Sep 22, 2018 · 3 revisions

Contents

About

The Romaji plugin converts words from Japanese letters to romaji (English letters). Currently, four different styles of romaji are supported: Traditional Hepburn, Modified Hepburn, Nihono-Shiki, and Kunrei-Shiki.

Example:
翔太しょうたはおばあさんと群馬ぐんまって、いっぱい抹茶まっちゃみました。

  • Traditional Hepburn: Shōta wa obaasan to Gumma ni itte, ippai matcha wo nomimashita.
  • Modified Hepburn: Shōta wa obāsan to Gunma ni itte, ippai matcha o nomimashita.
  • Nihono-Shiki: Syôta ha obâsan to Gunma ni itte, ippai mattya wo nomimasita.
  • Kunrei-Shiki: Syôta wa obâsan to Gunma ni itte, ippai mattya o nomimasita.
  • Wāpuro: Shouta ha obaasan to Gunma ni itte, ippai maccha wo nomimashita.

Styles can be set in the configuration file.

Usage

Romaji can be accessed for the entire text using the the LimelightResults object and romaji for individual words can be retrieved from the LimelightWord object. Both objects use the romaji() method to access romaji.


Get romaji for the entire text using the romaji() method.

$results = $limelight->parse('ライムの果実はレモンに似ています。');

$romaji = $results->romaji();

// [
//   'raimu',
//   'no',
//   'kajitsu',
//   'wa',
//   'remon',
//   'ni',
//   'niteimasu',
//   '.'

Use the string() method to build string of all romaji in the text.

$results = $limelight->parse('ライムの果実はレモンに似ています。');

$romaji = $results->string('romaji', ' ');

// 'raimu no kajitsu wa remon ni niteimasu.'

Get romaji for a single word with the romaji() method.

$results = $limelight->parse('ライムの果実はレモンに似ています。');

$romaji = $results->pull(2)->romaji();

// 'kajitsu'

Configuration

By default, Modified Hepburn style is used, but this can be changed in the config.php file.

Default configuration:

'Romaji' => [
    'style' => 'hepburn_modified'
]

Style values are as follows:

  • Modified Hepburn: 'hepburn_modified'
  • Traditional Hepburn: 'hepburn_traditional'
  • Nihon-Shiki: 'nihon_shiki'
  • Kunrei-Shiki: 'kunrei_shiki'
  • Wāpuro: 'wapuro'