PHP code example of fork-299132 / laravel-translation
1. Go to this page and download the library: Download fork-299132/laravel-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/ */
fork-299132 / laravel-translation example snippets
[
'missing_name' => 'Name is missing',
'missing_surname' => 'Surname is missing',
];
[
'missing_name' => 'Falta el nombre',
];
trans('validations.missing_name'); // 'Falta el nombre'
trans('validations.missing_surname'); // 'Surname is missing'
trans('validations.missing_email'); // 'validations.missing_email'
trans('validations.missing.name'); // 'Falta nombre'
trans('validations.min_number'); // 'Number is too small'
trans('validations.missing.email'); // 'missing_email'
trans('validations.missing_name'); // 'Falta el nombre'
trans('validations.missing_surname'); // 'Falta apellido'
trans('validations.min_number'); // 'Number is too small'
trans('validations.missing_email'); // 'missing_email'
\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 */
});
});