php-translation/symfony-bundle
Symfony bundle for the PHP Translation library. Integrates translation management, storage, and workflows into Symfony apps, with services and console tooling to import/export translations and keep locale files in sync across providers.
ramsey/composer-install) and minor bug fixes (e.g., Twig attribute guard), which do not introduce architectural shifts. Laravel’s integration approach (via ServiceProvider or facade wrappers) remains viable.twig_callable attribute suggests continued reliance on Twig, which may not be a priority for Laravel applications using Blade. However, this does not block core translation logic (e.g., loading, caching, or PHP-based translation).Loader, Translator) remains extractable, but Symfony-specific features (e.g., Twig filters) may require additional abstraction for Laravel.twig_callable ensures stability for Twig-based applications, but non-Twig Symfony apps (e.g., API-first) remain unaffected.Translator or Loader interfaces.ramsey/composer-install bump to v4 is unlikely to affect Laravel integrations, as this is a dev dependency for Composer scripts.CacheInterface or LoaderInterface, so Laravel’s emulation of these remains stable.twig_callable fix highlights Symfony’s Twig-centric design. Laravel users must explicitly opt out of Twig-related features (e.g., {{ 'message'|trans }} filters) if using Blade. Workaround: Restrict usage to PHP-based translation (e.g., $translator->trans()).translated events), so Laravel’s event listeners remain compatible.ramsey/composer-install update is isolated to dev workflows and poses no runtime risk.twig_callable fix is irrelevant, but the package’s Twig dependency may still bloat the installation.$translator->trans()) or also via templates? Blade users may need a custom Twig bridge or facade.Translation component (~10MB) plus Twig (~5MB). For Laravel, this may be acceptable if only PHP translation is used, but unnecessary for Blade-only apps.cache:pool:clear) or Laravel’s cache drivers? No changes here, but alignment may be needed for invalidation.__() for simplicity? The release does not preclude hybrid approaches.composer require php-translation/symfony-bundle:^0.17.1.config/bundles.php and configure in config/packages/translation.yaml.{{ 'message'|trans }}) or PHP ($translator->trans()).Translator to Laravel’s container via ServiceProvider:
// app/Providers/TranslationServiceProvider.php
public function register()
{
$this->app->singleton(\Symfony\Contracts\Translation\TranslatorInterface::class, function ($app) {
$loader = new \Symfony\Component\Translation\Loader\YamlFileLoader();
$translator = new \Symfony\Component\Translation\TranslatorLoader(
$loader,
$app['config']['translation.default_locale']
);
// Load translation files from Laravel’s `resources/lang/` or custom path
$translator->addResource('yaml', __DIR__.'/../../resources/lang/en/messages.yaml', 'en');
return $translator;
});
}
// app/Facades/Translator.php
public static function trans($id, array $parameters = [], $domain = null, $locale = null)
{
return app(\Symfony\Contracts\Translation\TranslatorInterface::class)->trans($id, $parameters, $domain, $locale);
}
laravel-bridge), install Twig and configure the bundle’s Twig extension. Note: This adds complexity and may not be worth the overhead for most Laravel apps.__()).laravel-localization) that may conflict.composer.json:
"require": {
"symfony/translation": "^6.4",
"php-translation/symfony-bundle": "^0.17.1"
},
"require-dev": {
"ramsey/composer-install": "^4.0" // Safe to update
}
TranslationServiceProvider (PHP-only, no Twig).__('key') with Translator::trans('key') or a custom facade.deprecated() helper.TranslatorInterface or LoaderInterface.translated) are not directly usable in Laravel without additional bridging (e.g., via Laravel events).symfony/translation is a widely used component with few Laravel conflicts.composer.json to ^0.17.1.composer update.TranslationServiceProvider (PHP-only).config/translation.php) for locale/path settings.__() calls incrementally, starting with non-critical paths.How can I help you explore Laravel packages today?