PHP code example of spletna-postaja / translatable
1. Go to this page and download the library: Download spletna-postaja/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/ */
spletna-postaja / 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
});