denismitr/translit

Russian-English Yandex transliteration package primarily for making slugs

v2.3 2017-07-14 18:29 UTC

README

##Version 2.2.5

Author

Denis Mitrofanov denis.mitr@gmail.com TheCollection

Installation

composer require denismitr/translit

##Usage

    $translit = new \Denismitr\Translit\Translit("Строка для транслитерации, по правилам Яндекс!");

    $slug = $translit->getSlug();
    //stroka-dlya-transliteracii-po-pravilam-yandeksa

or

    $slug = (new \Denismitr\Translit\Translit)->forString("Привет всем!")->getSlug();
    //privet-vsem

To process strings longer than 255 chars use getTranslit() instead of getSlug() that cuts max length of slug by default to 255

To define your own max length of the slug use

$slug = (new \Denismitr\Translit\Translit)->forString("длинный текст...")->setMaxLength(150)->getSlug();

or second parameter of Translit class constructor like this:

$translit = new Translit("some very very long text...", 20); //will cut the slug to 20 chars