denismitr / translit
Russian-English Yandex transliteration package primarily for making slugs
Installs: 5 573
Dependents: 4
Suggesters: 0
Security: 0
Stars: 14
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=7.2
Requires (Dev)
- phpspec/phpspec: ^6.0
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