PHP code example of guglielmoseminara / translatable
1. Go to this page and download the library: Download guglielmoseminara/translatable 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/ */
guglielmoseminara / translatable example snippets
use Laraplus\Data\Translatable;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use Translatable;
}
Post::first();
$post->title; // title in the current locale
Post::translateInto('de')->first();
$post->title; // title in 'de' locale
Post::translateInto('de')->withFallback('en')->first();
$post->title; // title in 'de' if available, otherwise in 'en'
'providers' => [
// other providers
Laraplus\Data\TranslatableServiceProvider::class
];
TranslatableConfig::currentLocaleGetter(function() {
// return the current locale of the application
});
TranslatableConfig::fallbackLocaleGetter(function() {
// return the fallback locale of the application
});