symfony/intl
Symfony Intl component provides access to ICU localization data in PHP: locales, languages, scripts, regions, currencies, and more. Includes tooling to compress bundled data (with zlib) for smaller installs and faster lookups.
symfony/intl package is a natural fit for Laravel’s existing i18n stack (e.g., Illuminate/Translation, Carbon for localization). Its ICU-backed approach complements Laravel’s multilingual features (e.g., locale-aware routing, localization middleware) without redundancy. The package’s PSR-compliant design ensures seamless integration with Laravel’s service container and facades (e.g., app('intl')).zlib) reduces payload size by ~30%, critical for Laravel SaaS apps with global users (e.g., Vapor deployments). No changes to this mechanism in v8.1.0.symfony/translation for hybrid i18n workflows).symfony/intl:^8.1).Carbon::locale() with IntlDateFormatter), then expand to pluralization or currency handling.__('key')) remains untouched; new features are additive.Intl::formatCurrency()) or service provider.assertEquals('€1,000.00', Intl::formatCurrency(1000, 'EUR'))).| Risk | Impact | Mitigation |
|---|---|---|
| ICU Data Staleness | Medium | Monitor Symfony’s ICU updates; self-host data if needed (package supports custom paths). |
| PHP Extension Dependency | Low | Requires intl PHP extension (enabled by default in Laravel Homestead/Valet). |
| Symfony Version Lock | Low | Pin to ^8.1 in composer.json to avoid major version surprises. |
| Edge-Case Localization | High (for niche regions) | Use as a foundation; extend with custom ICU rules for unsupported locales. |
| Compression Overhead | Low | Benchmark zlib vs. uncompressed data; disable if CPU-bound. |
compress script) or rely on runtime compression?symfony/intl for core + custom ICU rules) reduce risk?Intl as a singleton in AppServiceProvider:
$this->app->singleton('intl', function ($app) {
return new \Symfony\Component\Intl\Intl();
});
IntlFacade.php to expose methods (e.g., Intl::formatNumber()).config/intl.php for default locale/currency settings.Intl for locale-specific formatting (e.g., __(':amount', ['amount' => Intl::formatCurrency($value)])).Carbon::setLocale() with IntlDateFormatter for calendar/date rules.Illuminate\Validation\Rule with ICU-based rules (e.g., Rule::icuCurrency('EUR'))./api/intl/locales) for JavaScript frameworks (React/Vue) to use Intl polyfills.Carbon-based localization with IntlDateFormatter.IntlNumberFormatter for currency/percent formatting.en_US, fr_FR, ar_SA).Intl::selectPluralRule() for dynamic UI).ja_JP calendar, th_TH collation).php vendor/symfony/intl/Resources/bin/compress).IntlDateFormatter) in Laravel’s cache layer.vendor/symfony/intl/Resources/data).spatie/laravel-translation-manager (overlapping features). Mitigate by prioritizing Symfony Intl for ICU-specific tasks.laravel-excel for locale-aware CSV exports.| Step | Dependency | Owner | Timeline |
|---|---|---|---|
| 1. Setup Service Provider | Laravel core | Backend Lead | Week 1 |
| 2. Replace Carbon Localization | Carbon v2.0+ | Backend Team | Week 2 |
| 3. Add Facade | Service Provider | TPM | Week 1 |
| 4. Test Core Locales | Phase 1 features | QA | Week 3 |
| 5. Advanced Features | Phase 2 requirements | Full-Stack Team | Week 5 |
| 6. Compress ICU Data | CI/CD pipeline | DevOps | Week 6 |
| 7. Frontend Integration | API endpoints | Frontend Lead | Week 4 |
composer update symfony/intl --with-dependencies in a staging environment.NOK in v7.3.1).vendor/symfony/intl/Resources/data to app/Data/intl and updating composer.json autoload paths.Log::error() for observability.composer dump-autoload).Intl calls with Xdebug; cache frequently used formattersHow can I help you explore Laravel packages today?