https://github.com/atomjoy/trans
Laravel translations from the database.
https://github.com/atomjoy/trans
laravel-translation laravel-translations
Last synced: 3 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 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-16T11:30:13.000Z (over 2 years ago)
- Last Synced: 2025-02-08T22:48:05.206Z (4 months 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 ...';
}
});
```