This library allows you to effortlessly convert Serbian personal names to their correct vocative form in your Laravel application.
You can install the package via composer:
composer require oblak/vocative-laravel
You can publish the config file with:
php artisan vendor:publish --tag="vocative-config"
This is the contents of the published config file:
<?php
return [
'dictionary' => [],
'ignore_dictionary' => false,
];
You can use the package in your application by calling the Vocative
class directly or using the provided Blade directives.
You can use the Vocative
facade to transform names to their vocative form:
use Oblak\Vocative\Facades\Vocative;
// Transform a name to vocative case
echo Vocative::make('Милица'); // "Милице"
echo Vocative::make('Марко'); // "Марко"
// Force transformation (bypass dictionary)
echo Vocative::make('Лука', true); // Forces transformation even if in dictionary
The package provides two Blade directives for convenient use in your templates:
{{-- Using @vocative directive --}}
Hello, @vocative('Милица')!
{{-- Using the shorter @voc alias --}}
Hello, @voc('Марко')!
You can define custom vocative forms in the configuration file:
// config/vocative.php
return [
'dictionary' => [
'CUSTOM_NAME' => 'CUSTOM_VOCATIVE_FORM',
'Лука' => 'Луко',
],
'ignore_dictionary' => false, // Set to true to always force transformation
];
composer test
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.