PHP code example of yebto / laravel-transliterator-api

1. Go to this page and download the library: Download yebto/laravel-transliterator-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yebto / laravel-transliterator-api example snippets


use TransliteratorAPI;

// basic
$result = TransliteratorAPI::transliterate('bg', 'Дядовите чички');

/*
[
    "lang"      => "bg",
    "type"      => "plain",
    "delimiter" => "-",
    "original"  => "Дядовите чички",
    "result"    => "Dyadovite chichki"
]
*/

// slug with custom delimiter
TransliteratorAPI::transliterate(
    lang:      'ru',
    text:      'Мой дядя самых честных правил',
    type:      'slug',
    delimiter: '_'
); // => "moy_dyadya_samykh_chestnykh_pravil"

Route::post('/transliterator', function () {
    return TransliteratorAPI::transliterate(
        request('lang'),
        request('text'),
        request('type', 'plain'),
        request('delimiter', '-')
    );
});

class GenerateFilename implements ShouldQueue
{
    public function handle()
    {
        $slug = TransliteratorAPI::transliterate(
            'el',
            $this->originalTitle,
            'slug'
        )['result'];

        // ...
    }
}