PHPackages                             coroq/form-lang-ja - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. coroq/form-lang-ja

ActiveLibrary[Localization &amp; i18n](/categories/localization)

coroq/form-lang-ja
==================

v1.0.0(7mo ago)01MITPHPPHP ^8.0

Since Oct 30Pushed 7mo agoCompare

[ Source](https://github.com/coroq-com/coroq-form-lang-ja)[ Packagist](https://packagist.org/packages/coroq/form-lang-ja)[ RSS](/packages/coroq-form-lang-ja/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (4)Used By (0)

Coroq Form Lang Ja
==================

[](#coroq-form-lang-ja)

Japanese language extension for [coroq/form](https://github.com/ozami/coroq-form). Provides Japanese-specific form inputs with automatic character conversion and validation.

Features
--------

[](#features)

- **KatakanaInput** - Validates katakana characters only
- **HiraganaInput** - Validates hiragana characters only
- **BasicErrorMessages** - Japanese error messages for all form errors

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

[](#installation)

```
composer require coroq/form-lang-ja
```

Requires:

- PHP ^8.0
- coroq/form ^3.0

Quick Start
-----------

[](#quick-start)

```
use Coroq\Form\Form;
use Coroq\Form\Lang\Ja\FormItem\KatakanaInput;
use Coroq\Form\Lang\Ja\FormItem\HiraganaInput;

class NameForm extends Form {
    public readonly KatakanaInput $nameKana;
    public readonly HiraganaInput $nameHiragana;

    public function __construct() {
        $this->nameKana = new KatakanaInput();
        $this->nameHiragana = new HiraganaInput();
    }
}

$form = new NameForm();
$form->setValue([
    'nameKana' => 'やまだ たろう',      // Hiragana input
    'nameHiragana' => 'ヤマダ タロウ'   // Katakana input
]);

if ($form->validate()) {
    echo $form->nameKana->getValue();      // "ヤマダ　タロウ" (converted to katakana)
    echo $form->nameHiragana->getValue();  // "やまだ　たろう" (converted to hiragana)
}
```

KatakanaInput
-------------

[](#katakanainput)

Automatically converts input to katakana and validates that the result contains only katakana characters.

```
use Coroq\Form\Form;
use Coroq\Form\Lang\Ja\FormItem\KatakanaInput;

class UserForm extends Form {
    public readonly KatakanaInput $furigana;

    public function __construct() {
        $this->furigana = (new KatakanaInput())
            ->setLabel('フリガナ')
            ->setMaxLength(50);
    }
}

$form = new UserForm();

// Automatic conversion to katakana
$form->furigana->setValue('やまだたろう');  // Hiragana
echo $form->furigana->getValue();  // "ヤマダタロウ" (katakana)

$form->furigana->setValue('ﾔﾏﾀﾞﾀﾛｳ');     // Half-width
echo $form->furigana->getValue();  // "ヤマダタロウ" (full-width)

// Validation
$form->furigana->setValue('山田太郎');  // Kanji
$form->validate();  // false - NotKatakanaError

$form->furigana->setValue('ABC123');   // Alphabet/numbers
$form->validate();  // false - NotKatakanaError
```

### Accepted Characters

[](#accepted-characters)

- Katakana: ァ-ヴ
- Long dash: ー (used in コーヒー, タクシー)
- Combining marks: ゙゚ (for Unicode normalization)

### Type-Safe Access

[](#type-safe-access)

```
// Returns validated katakana string or null if invalid/empty
$katakana = $form->furigana->getKatakana();  // string|null
```

HiraganaInput
-------------

[](#hiraganainput)

Automatically converts input to hiragana and validates that the result contains only hiragana characters.

```
use Coroq\Form\Form;
use Coroq\Form\Lang\Ja\FormItem\HiraganaInput;

class CommentForm extends Form {
    public readonly HiraganaInput $reading;

    public function __construct() {
        $this->reading = (new HiraganaInput())
            ->setLabel('よみがな')
            ->setMaxLength(100);
    }
}

$form = new CommentForm();

// Automatic conversion to hiragana
$form->reading->setValue('ヤマダタロウ');  // Katakana
echo $form->reading->getValue();  // "やまだたろう" (hiragana)

$form->reading->setValue('ﾔﾏﾀﾞﾀﾛｳ');     // Half-width
echo $form->reading->getValue();  // "やまだたろう" (hiragana)

// Long dash is accepted
$form->reading->setValue('こーひー');
$form->validate();  // true
```

### Accepted Characters

[](#accepted-characters-1)

- Hiragana: ぁ-ゔ
- Long dash: ー (less common in hiragana, but accepted)
- Combining marks: ゙゚ (for Unicode normalization)

### Type-Safe Access

[](#type-safe-access-1)

```
// Returns validated hiragana string or null if invalid/empty
$hiragana = $form->reading->getHiragana();  // string|null
```

Error Messages
--------------

[](#error-messages)

`BasicErrorMessages` is a predefined set of Japanese error messages that can be used as-is or as a starting point for customization:

```
use Coroq\Form\ErrorMessageFormatter;
use Coroq\Form\Lang\Ja\BasicErrorMessages;

$formatter = new ErrorMessageFormatter();
$formatter->setMessages(BasicErrorMessages::get());

$form->validate();

if ($form->furigana->hasError()) {
    echo $formatter->format($form->furigana->getError());
    // "カタカナで入力してください"
}
```

### Included Messages

[](#included-messages)

```
// Japanese-specific errors
NotKatakanaError => "カタカナで入力してください"
NotHiraganaError => "ひらがなで入力してください"

// Common errors (from coroq/form)
EmptyError => "入力してください" or "選択してください"
InvalidError => "正しく入力してください"
InvalidEmailError => "正しいメールアドレスを入力してください"
InvalidUrlError => "正しい URL を入力してください"
TooLongError => "{length} 文字以内で入力してください"
TooShortError => "{length} 文字以上で入力してください"
TooSmallError => "{min} 以上の値を入力してください"
TooLargeError => "{max} 以下の値を入力してください"
NotIntegerError => "整数を入力してください"
// ... and more
```

### Customizing Messages

[](#customizing-messages)

```
use Coroq\Form\ErrorMessageFormatter;
use Coroq\Form\Lang\Ja\BasicErrorMessages;
use Coroq\Form\Lang\Ja\Error\NotKatakanaError;

$formatter = new ErrorMessageFormatter();

// Start with defaults
$messages = BasicErrorMessages::get();

// Override specific messages
$messages[NotKatakanaError::class] = "全角片仮名で入力してください";

$formatter->setMessages($messages);
```

Testing
-------

[](#testing)

```
composer test
composer coverage       # HTML coverage report → coverage/
composer coverage-text  # Text coverage report
```

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance63

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

3

Last Release

224d ago

PHP version history (2 changes)1.0.0-alpha1PHP &gt;=8.0

v1.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/addac0ea12d91786ce888c91ef7de6525bc17252c702cd7e48fe64ab547c012e?d=identicon)[ozami](/maintainers/ozami)

---

Top Contributors

[![ozami](https://avatars.githubusercontent.com/u/170309?v=4)](https://github.com/ozami "ozami (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coroq-form-lang-ja/health.svg)

```
[![Health](https://phpackages.com/badges/coroq-form-lang-ja/health.svg)](https://phpackages.com/packages/coroq-form-lang-ja)
```

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
