boshurik / twig-petrovich-extension
Twig Petrovich extension
0.1.0
2020-06-17 16:58 UTC
Requires
- php: ^7.2
- staticall/petrovich-php: ^1.4
- twig/twig: ^2.10 | ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpunit/phpunit: ^8.5
- vimeo/psalm: ^3.11
This package is auto-updated.
Last update: 2024-10-25 20:09:45 UTC
README
Installation
composer req boshurik/twig-petrovich-extension
use Staticall\Petrovich\Petrovich; use Staticall\Petrovich\Petrovich\Loader; use BoShurik\Petrovich\Twig\Extension\PetrovichExtension; use Twig\Environment; $petrovich = new Petrovich(Loader::load('/path/to/rules.json')); $extension = new PetrovichExtension($petrovich); $twig = new Environment($loader); $twig->addExtension($extension);
You can use callable to lazy loading Petrovich
instance
use Staticall\Petrovich\Petrovich; use Staticall\Petrovich\Petrovich\Loader; use BoShurik\Petrovich\Twig\Extension\PetrovichExtension; $factory = function () { return new Petrovich(Loader::load('/path/to/rules.json')); }; $extension = new PetrovichExtension($factory);
Usage
{{ 'Тестов Тест Тестович' | inflect_full_name('genitive', 'male') }} {{ 'Тестов Тест Тестович' | inflect_full_name('dative') }} {{ 'Тестов Тест Тестович' | inflect_full_name_accusative }} {{ 'Тестов Тест Тестович' | inflect_full_name_instrumental_male }} {{ inflect_full_name('Тестов Тест Тестович', 'genitive', 'male') }} {{ inflect_full_name('Тестов Тест Тестович', 'dative') }} {{ inflect_full_name_accusative('Тестов Тест Тестович') }} {{ inflect_full_name_instrumental_male('Тестов Тест Тестович') }}