Pros:
.json/.php files).trans() helper (via Symfony’s Translation component or custom bridges like symfony/translation).Route::prefix('api/translations')->group(...)) for RESTful management.messages, validators) mirrors Laravel’s translation domains, reducing merge conflicts in monolithic .po/.json files.Cons:
TranslationManager, DependencyInjection) may require Laravel-specific wrappers or adapters (e.g., Service Providers, Facades).trans() with this bundle’s TranslationManager via a custom Service Provider.Route::resource() or Route::apiResource() to expose the same endpoints (e.g., /api/translations).dahovitech_translations table to Laravel’s schema (e.g., php artisan make:migration create_translations_table).cache()->remember()) via the bundle’s enable_cache config.Translation Component: Laravel’s trans() uses a different loader system. A bridge (e.g., SymfonyTranslationLoader) would be needed.translation.updated) may require Laravel’s Event facade adapters.symfony/translation, symfony/dependency-injection) may increase bundle size and complexity.DB::enableQueryCache()).domain column) could break existing translations if not handled via Laravel migrations.TranslationManager → LaravelTranslationService).resources/lang).trans() calls? Will we need a custom Translator facade?getTranslation() calls? Can we optimize with Laravel’s query caching?resources/lang/fr/messages.php) to the DB?Laravel Compatibility:
HttpFoundation, Console, and Translation components. This bundle adds DependencyInjection and Doctrine, which are optional but require:
AppServiceProvider::boot().Translation model) or a lightweight ORM like CycleORM.Route::prefix() to map Symfony’s routes (e.g., Route::prefix('api')->group(...)).config/translator.php (e.g., using config(['translator' => $bundleConfig])).Hybrid Architecture:
resources/lang for unchanging content (e.g., UI strings).fallback_locale in Laravel’s AppServiceProvider to match the bundle’s settings.Phase 1: Proof of Concept (2 weeks)
messages) with the bundle’s DB-backed system.trans() calls, API endpoints, and missing translation detection.Phase 2: Partial Migration (4 weeks)
fr) for a subset of domains (e.g., validators).php artisan translator:import).getTranslation() calls.auth:sanctum).Phase 3: Full Rollout (3 weeks)
TranslationManager to Laravel’s container:
$this->app->singleton(TranslationManager::class, function ($app) {
return new TranslationManager(
$app->make(TranslationRepository::class),
$app->get('config')['translator']
);
});
trans():
use Dahovitech\TranslatorBundle\Loader\DatabaseLoader;
$translator->addLoader('db', new DatabaseLoader($translationManager));
translation.updated → TranslationUpdated).dahovitech_translations table to Laravel’s conventions:
Schema::create('translations', function (Blueprint $table) {
$table->id();
$table->string('translation_key');
$table->string('locale');
$table->text('content');
$table->string('domain');
$table->timestamps();
$table->index(['translation_key', 'locale']);
});
tests/Feature/TranslationApiTest).Translation::where('locale', 'fr')->get()).Cache::forget('translations.fr')).Prerequisites:
composer require dahovitech/translator-bundle symfony/translation symfony/dependency-injection
Translation entity.Core Integration:
config/app.php:
'providers' => [
Dahovitech\TranslatorBundle\DahovitechTranslatorBundle::class,
],
php artisan vendor:publish --tag="dahovitech-translator-config"
How can I help you explore Laravel packages today?