Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 1011 Bytes

README.md

File metadata and controls

39 lines (31 loc) · 1011 Bytes

Yandex-standard russian-english transliteration

Version

3.0 requires PHP >= 7.2

Author

Denis Mitrofanov denis.mitr@gmail.com

Installation

composer require denismitr/translit

Usage

    $translit = new \Denismitr\Translit\Translit();

    $slug = $translit->transform("Строка для транслитерации, по правилам Яндекс!");
    //stroka-dlya-transliteracii-po-pravilam-yandeksa

To define max length of the output do:

$slug = (new \Denismitr\Translit\Translit)->transform("очень длинный текст...", 10);
// ochen-dlin

You can provide your own translit implementation as long as it implements the \Denismitr\Translit\TranslitStrategy interface and inject it into the Translit class constructor, this way it will override the default behavior like so:

new \Denismitr\Translit\Translit(new YourTranslitStrategyImpl());

Run tests

composer test