PHPackages                             jv/jvfurigana - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. jv/jvfurigana

ActiveLibrary[Templating &amp; Views](/categories/templating)

jv/jvfurigana
=============

A view helper that can convert plain japanese text into properly formatted HTML with furigana (using the ruby tag).

7171PHP

Since Aug 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/poisa/JVFurigana)[ Packagist](https://packagist.org/packages/jv/jvfurigana)[ RSS](/packages/jv-jvfurigana/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

JVFurigana
==========

[](#jvfurigana)

### ZF2 Module for adding furigana to japanese text

[](#zf2-module-for-adding-furigana-to-japanese-text)

Version 1.0 Created by [Julian Vidal](http://julianvidal.com/)

What exactly is furigana?
-------------------------

[](#what-exactly-is-furigana)

[Furigana](http://en.wikipedia.org/wiki/Furigana) according to Wikipedia is:

> A Japanese reading aid, consisting of smaller kana, or syllabic characters, printed next to a kanji (ideographic character) or other character to indicate its pronunciation. It is typically used to clarify rare, nonstandard or ambiguous readings, or in children's or learners' materials.

Simply put, you could know how to *read* a certain word in Japanese but that doesn't necessarily mean that you know how to pronounce it. To solve this problem, publishers use furigana to tell the reader how a particular word is pronounced.

A Japanese sentence looks like this:

林さんは英語は話せます。

To add a phonetic guide it is common practice to include the pronunciations between parenthesis right after the kanji, like this:

林（はやし）さんは英語（えいご）は話（はな）せます。

While this makes pronunciations very clear it makes the text less readable.

This module takes furigana entered in the above format and converts it to proper HTML using **ruby**, **rb**, **rp**, and **rt** tags. This will turn the above sentence into this:

```
林(はやし)さんは英語(えいご)は話(はな)せます。

```

Supported browsers (like Chrome) will render it like this:

[![Rendered furigana](https://camo.githubusercontent.com/223cd5d9c39df4a6c5aed397d19713b7becdd3e823e3d91a6909a823f305ec2d/68747470733a2f2f6a756c69616e766964616c2e636f6d2f696d616765732f6675726967616e612e706e673f31)](https://camo.githubusercontent.com/223cd5d9c39df4a6c5aed397d19713b7becdd3e823e3d91a6909a823f305ec2d/68747470733a2f2f6a756c69616e766964616c2e636f6d2f696d616765732f6675726967616e612e706e673f31)

And a nice advantage is that browsers that don't support ruby text will degrade gracefully and render your text exactly as you entered it. Actually the text will *look* the same but since the furigana will now be wrapped in its own tags, you will be able to style them the way you want. You couldn't have done this without ruby tags. So as you see the **ruby** tag has its benefits.

Installation
------------

[](#installation)

You can install this module in different ways. The easiest one is by using composer. For this to work you need to add the module to your `require` section in the composer.json file:

```
"require": {
    "jv/jvfurigana": "dev-master"
}

```

Then run: `php composer.phar update`

If you don't want to use composer, you can clone or download this repository into your ZF2 modules directory.

**Whatever way you choose, don't forget to enable the module in your** `config/application.config.php` **file.**

Usage
-----

[](#usage)

From within a view script, you can do:

```
