Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Translation Bundle

Translation Bundle Laravel Package

alessandrolandim/translation-bundle

View on GitHub
Deep Wiki
Context7

This Symfony bundle allow to import translation files content into the database and provide a GUI to edit translations.

Frequently asked questions about Translation Bundle
Can I use LexikTranslationBundle in Laravel instead of Symfony?
The bundle is Symfony-first, but you can adapt it for Laravel by using Symfony’s standalone components (e.g., `symfony/translation`) and building a custom facade to integrate with Laravel’s service container. The database storage and import/export logic can work with Eloquent, but the GUI and Symfony-specific features (like Doctrine ORM) will require abstraction or replacement.
How do I import existing translation files (YAML/PHP) into the database?
Run the bundle’s CLI command (e.g., `lexik:translation:import`) to load files into the database. In Laravel, you’d need to replicate this with an Artisan command or a custom script that reads files and inserts records into your translations table. The bundle’s `DatabaseLoader` ensures database entries override file-based translations.
Will this bundle work with Laravel’s native `trans()` helper?
No, not out of the box. You’ll need to create a custom translator facade in Laravel that extends Symfony’s `Translator` and overrides Laravel’s default loader. This facade should prioritize database translations over file-based ones, mimicking the bundle’s behavior.
Does the admin GUI work in Laravel, or do I need to rebuild it?
The GUI is Symfony-specific (Twig + Controllers), so you’ll need to rebuild it for Laravel. Options include using Laravel admin packages like Filament or Nova, creating a Blade-based interface, or exposing translations via an API for a SPA frontend.
What Laravel versions are supported, and are there compatibility issues?
The bundle targets Symfony 5.2+, but Laravel compatibility depends on your integration approach. If you use standalone Symfony components (e.g., `symfony/translation`), it may work with Laravel 8+ or 9+. However, Symfony’s Doctrine ORM dependency could conflict with Eloquent unless you abstract it.
How do I handle translations for a multi-tenant Laravel app?
Store tenant-specific translations in the database with a `tenant_id` column in your translations table. Use Laravel’s Eloquent scopes or query constraints to filter translations by tenant. The bundle’s import/export logic can be extended to include tenant-specific files or commands.
Are there performance concerns with database-backed translations?
Yes, database queries can be slower than file I/O for large translation sets. Mitigate this by caching translations in Redis or Laravel’s cache system. The bundle’s `DatabaseLoader` can be optimized with query batching or lazy-loading.
Can I export translations back to files for version control?
The bundle supports exporting database translations to files (YAML/PHP) via CLI. In Laravel, you’d need to replicate this with a custom Artisan command that queries your translations table and writes files. This is useful for backups or collaboration with translators.
What’s the best alternative for Laravel if I don’t want Symfony dependencies?
Consider Laravel-specific packages like `spatie/laravel-translatable` (for model translations) or `mcamara/laravel-localization` (for route/localization). For database-backed translations, build a custom solution using Eloquent and Laravel’s service container, or use a hybrid approach with file-based fallbacks.
How do I test translations in Laravel with this bundle?
Mock the custom translator facade and database interactions in your tests. Use Laravel’s testing helpers (e.g., `actingAs`, `refreshDatabase`) to simulate user-specific translations. For the GUI, test API endpoints or Blade views separately, as the Symfony-specific components won’t run in Laravel’s test environment.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware