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

Intl Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Provides access to the localization data of the ICU library

Frequently asked questions about Intl
How does symfony/intl integrate with Laravel’s built-in translation system (e.g., `__()` or `trans()`)?
Symfony Intl doesn’t replace Laravel’s translation system but enhances it. Use it for dynamic formatting (e.g., `Intl::formatCurrency()`) inside translation strings like `__(':amount', ['amount' => Intl::formatCurrency($value)])`. For static translations, keep using Laravel’s `__()` or `trans()`, while leveraging Intl for locale-specific formatting rules.
Can I use symfony/intl for complex pluralization (e.g., Arabic, Russian) in Laravel?
Yes. Symfony Intl’s ICU-based pluralization handles complex rules out of the box. Replace Laravel’s basic pluralization logic (e.g., `str_plural()`) with `Intl::selectFormat()` or `Intl::pluralRules()`. Works seamlessly with Laravel’s localization middleware and locale-aware routes.
What Laravel versions and PHP versions does symfony/intl support?
Symfony Intl ^8.1 requires PHP 8.1+, which aligns perfectly with Laravel 10.x+. For Laravel 9.x, use symfony/intl ^6.3 (PHP 8.0+). Always pin the version in `composer.json` (e.g., `^8.1`) to avoid surprises. The package is PSR-compliant, so no Laravel-specific conflicts exist.
How do I compress ICU data for smaller Laravel deployments (e.g., Vapor)?
Run `php vendor/symfony/intl/Resources/bin/compress` in your project root to compress ICU data with zlib. This reduces payload size by ~30%. Ensure the `zlib` PHP extension is enabled (default in Laravel Homestead/Valor). For CI/CD, automate this step in your build pipeline.
Will symfony/intl break existing Laravel localization code (e.g., Carbon’s `setLocale()`)?
No. Symfony Intl is additive. For dates/times, replace `Carbon::setLocale()` with `IntlDateFormatter` for calendar-specific rules (e.g., Hijri, Japanese). Existing `__()` or `Carbon` code remains unchanged. Use both in hybrid workflows (e.g., Carbon for parsing, Intl for display).
How do I expose ICU data to frontend frameworks (React/Vue) in a Laravel app?
Create an API endpoint (e.g., `/api/intl/locales`) returning ICU data (e.g., `Intl::getLocales()`). Frontend frameworks can use the `Intl` polyfill or native APIs. For dynamic formatting, return formatted values (e.g., `Intl::formatCurrency()`) via JSON responses to avoid client-side ICU dependency.
Are there performance trade-offs for using compressed ICU data in production?
Compressed ICU data reduces payload size but adds minor CPU overhead during decompression. Benchmark your use case: for most Laravel apps, the trade-off is worth it (~30% smaller payload). Disable compression only if CPU-bound (e.g., serverless functions with tight limits).
What’s the best way to test ICU-based localization in Laravel’s PHPUnit?
Use deterministic ICU outputs in assertions (e.g., `assertEquals('€1.000,00', Intl::formatCurrency(1000, 'EUR'))`). Test edge cases like RTL languages (e.g., Arabic) or complex pluralization. Mock `Intl` services in unit tests via Laravel’s service container. For integration tests, verify locale-aware routes and middleware.
How do I handle unsupported locales or custom ICU rules in Laravel?
Symfony Intl covers 99% of global locales, but for niche cases, extend it by loading custom ICU data paths (e.g., `Intl::setDataDirectory()`). For hybrid workflows, combine Intl with custom logic (e.g., override `Intl::pluralRules()` for region-specific tweaks). Document unsupported locales in your app’s `config/intl.php`.
What alternatives exist for Laravel i18n if symfony/intl feels too heavy?
For lightweight needs, use `php-intl` (PHP’s built-in extension) or `voku/portable-ascii` for basic formatting. For translation-only (not localization), stick with Laravel’s `Illuminate/Translation`. If you need ICU’s power but want modularity, consider `symfony/intl` alongside `laravel-localization` for a hybrid approach.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony