shaunthegeek / laravel-lang-db
Manage Laravel translations in the database and export them to JSON files.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 2
pkg:composer/shaunthegeek/laravel-lang-db
Requires
- laravel/framework: >=v10
Requires (Dev)
- laravel/pint: ^1.27
- orchestra/testbench: >=v8.0.0
- pestphp/pest: ^4.3
README
Manage Laravel translations in the database and export them to JSON files.
Installation
composer require shaunthegeek/laravel-lang-db
Usage
- Run migrations to create the table:
php artisan vendor:publish --tag=laravel-lang-db-migrations php artisan migrate
- Import translations from
/langdirectory to database:
php artisan lang:import
This will read all .json files in /lang and populate the database. By default, it skips existing keys. Use --force to update existing records:
php artisan lang:import --force
- Add translations to the
languagestable, either by directly operating the database or via the admin interface (e.g., FilamentPHP).
| locale | key | value |
|---|---|---|
| en | messages.welcome | Welcome |
| zh_CN | messages.welcome | 欢迎 |
- Export translations to
/langdirectory:
php artisan lang:export
This will create/update:
/lang/en.json/lang/zh_CN.json
Testing
composer test