1. Go to this page and download the library: Download behzadbabaei/translation 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/ */
\Schema::create('examples', function ($table) {
$table->increments('id');
$table->string('slug')->nullable();
$table->string('title')->nullable();
$table->string('title_translation')->nullable();
$table->string('text')->nullable();
$table->string('text_translation')->nullable();
$table->timestamps();
});
class Example extends Model
{
use \Waavi\Translation\Traits\Translatable;
protected $translatableAttributes = ['title', 'text'];
}
// If the middleware is globally applied:
Route::group(['prefix' => \UriLocalizer::localeFromRequest()], function(){
/* Your routes here */
});
// For selectively chosen routes:
Route::group(['prefix' => \UriLocalizer::localeFromRequest(), 'middleware' => 'localize')], function () {
/* Your routes here */
});
// For selectively chosen routes:
Route::group(['prefix' => 'api/v1'], function() {
/** ... Non localized urls here **/
Route::group(['prefix' => \UriLocalizer::localeFromRequest(2), 'middleware' => 'localize:2')], function () {
/* Your localized routes here */
});
});