1. Go to this page and download the library: Download atomjoy/trans 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/ */
atomjoy / trans example snippets
use Illuminate\Support\Facades\Route;
use Trans\Models\Translate;
Route::get('/trans', function () {
try {
// Clear cache (in Seeder)
Translate::clearCache();
// Add translation for locale (in Seeder)
Translate::add('Hello','Witaj', 'pl');
// Change locale
app()->setLocale('pl');
// If exists in db
echo "<br> PL " . trans_db('Hello');
// If not exists in db get translation from default trans() helper
echo "<br> PL " . trans_db('This text not exists in db');
} catch (Exception $e) {
report($e);
return 'Errors ...';
}
});
sh
# locales
php artisan lang:publish
# update tables
php artisan migrate
# new tables
php artisan migrate:fresh
json
{
"This text not exists in db": "Ten tekst nie istnieje w bazie danych"
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.