PHP code example of that0n3guy / transliteration

1. Go to this page and download the library: Download that0n3guy/transliteration 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/ */

    

that0n3guy / transliteration example snippets


'providers' => array(

    'Illuminate\Foundation\Providers\ArtisanServiceProvider',
    'Illuminate\Auth\AuthServiceProvider',
    ...
    'That0n3guy\Transliteration\TransliterationServiceProvider',

),

Route::get('/test', function(){
  echo Transliteration::clean_filename('test& ® is true');
});

Route::get('/test', function(){
  echo Transliteration::clean_filename('testing Japanese 日本語', 'jpn');
});

// if using transliteration
if (class_exists( 'That0n3guy\Transliteration\Transliteration' )) {
  $file->fileSystemName = Transliteration::clean_filename($file->getClientOriginalName());  // You can see I am cleaning the filename
}

/**
 * Stores new upload
 *
 */
public function store()
{
    $file = Input::file('file');

    // if using transliteration
    if (class_exists( 'That0n3guy\Transliteration\Transliteration' )) {
      $file->fileSystemName = Transliteration::clean_filename($file->getClientOriginalName());
    }

    $upload = new Upload;

    try {
        $upload->process($file);
    } catch(Exception $exception){
        // Something went wrong. Log it.
        Log::error($exception);
        $error = array(
            'name' => $file->getClientOriginalName(),
            'size' => $file->getSize(),
            'error' => $exception->getMessage(),
        );
        // Return error
        return Response::json($error, 400);
    }

    // If it now has an id, it should have been successful.
    if ( $upload->id ) {
      ...

that0n3guy
    drivers
        config
            config.php
        Plugin.php


use Illuminate\Support\Facades\Config;

$config = [
    // This contains the Laravel Packages that you want this plugin to utilize listed under their package identifiers
    'packages' => [
        'that0n3guy/transliteration'  => [
            'providers' => [
                '\That0n3guy\Transliteration\TransliterationServiceProvider',
            ],
            'aliases' => [
                'Transliteration' => '\That0n3guy\Transliteration\Facades\Transliteration',
            ],
        ],

    ],
];

return $config;