PHP code example of ozanakman / laravel-multilingual

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

    

ozanakman / laravel-multilingual example snippets


return [
    /*
     * How we should treat urls to get the selected language?
     * http://{domain}.site.com
     * http://site.com/{path}
     *
     * Supported: "domain", "path"
     */
    'pattern' => 'path',

    /**
     * Localization middleware to handle user redirects.
     */
    'middleware' => OzanAkman\Multilingual\Middleware\Localize::class,
];
 
 Route::locale(function () {
     Route::get('/home', function () {
         return view('welcome');
     });
 });
 
  
  Route::locale(['middleware' => 'auth'], function () {
      Route::get('/invoice/{invoiceId}', 'InvoiceController@show');
  });
  

$model->translate('en');

$model->translate('en', [
    'column' => 'translated_version'
]);
 
$model->removeTranslation('en');

class ExampleModel extends Model
{
    public function slugSource()
    {
        // Column
        return 'title';
    }
}
sh
php artisan multilingual:install
bash 
php artisan multilingual:add tr Turkish Türkçe
bash 
php artisan multilingual:remove tr