atomjoy / trans
Laravel database translations.
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/atomjoy/trans
This package is not auto-updated.
Last update: 2025-10-01 06:49:49 UTC
README
Laravel translations from database.
Install
composer require "atomjoy/trans"
composer update
composer dump-autoload -o
Migrate, locales
# locales php artisan lang:publish # update tables php artisan migrate # new tables php artisan migrate:fresh
Laravel trans
lang/pl.json
{ "This text not exists in db": "Ten tekst nie istnieje w bazie danych" }
Examples
routes/web.php
<?php 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 ...'; } });