https://github.com/atomjoy/trans
Laravel translations from the database.
https://github.com/atomjoy/trans
laravel-translation laravel-translations
Last synced: 12 months ago
JSON representation
Laravel translations from the database.
- Host: GitHub
- URL: https://github.com/atomjoy/trans
- Owner: atomjoy
- Created: 2023-02-15T13:58:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-16T11:30:13.000Z (over 3 years ago)
- Last Synced: 2025-06-08T22:02:09.518Z (about 1 year ago)
- Topics: laravel-translation, laravel-translations
- Language: PHP
- Homepage: https://github.com/atomjoy/trans
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel Translations
Laravel translations from database.
## Install
```sh
composer require "atomjoy/trans"
composer update
composer dump-autoload -o
```
## Migrate, locales
```sh
# locales
php artisan lang:publish
# update tables
php artisan migrate
# new tables
php artisan migrate:fresh
```
## Laravel trans
lang/pl.json
```json
{
"This text not exists in db": "Ten tekst nie istnieje w bazie danych"
}
```
## Examples
routes/web.php
```php
setLocale('pl');
// If exists in db
echo "
PL " . trans_db('Hello');
// If not exists in db get translation from default trans() helper
echo "
PL " . trans_db('This text not exists in db');
} catch (Exception $e) {
report($e);
return 'Errors ...';
}
});
```