denismitr/translit

Russian-English Yandex transliteration package primarily for making slugs

v3.0.1 2020-11-02 09:33 UTC

This package is auto-updated.

Last update: 2024-11-29 05:09:29 UTC


README

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