binsoul/common-i18n-intl
Intl-based i18n helpers for PHP from binsoul/common-i18n. Provides locale-aware formatting and parsing for numbers, currencies, dates/times, and messages via the PHP Intl extension, to simplify building internationalized apps and libraries.
binsoul/common-i18n-intl) leverages PHP’s Intl extension for ICU-compliant internationalization, aligning well with Laravel’s built-in localization system (trans(), Lang facade). It may offer advanced features like pluralization, gendered forms, and locale-aware formatting that Laravel’s default laravel-translation-manager or laravel-i18n lack.Intl extension is CPU-intensive. Benchmarking is critical—especially for high-traffic APIs or CLI-heavy workflows.App::setLocale() and config('app.locale'), but may conflict with existing translation managers (e.g., spatie/laravel-translation-loader). Middleware/Service Provider hooks will be needed to ensure seamless integration.resources/lang structure may require custom loaders.en → es) must be explicitly configured in the package to avoid runtime errors.Intl extension is not enabled by default in all PHP environments (e.g., shared hosting). Docker/Composer constraints (ext-intl: *) must be documented.translator->get()) may differ from Laravel’s trans() helper, requiring wrapper classes or facade overrides.trans() + Intl directly? Does this package add critical functionality (e.g., compiled translation caching, CLI tools)?.json, .php) be migrated without breaking existing trans() calls?Intl-based pluralization vs. hardcoded rules?ext-intl is unavailable (e.g., graceful degradation)?SetLocaleMiddleware)?Intl and Laravel’s Lang facade minimizes refactoring. However, custom facades may be needed to bridge gaps (e.g., IntlTranslator::trans() vs. trans()).trans() helper (no direct frontend impact).localizations table or requires a new table.composer require binsoul/common-i18n-intl).trans('key') with translator()->get('key') in critical paths.en, es, ar) to validate pluralization/gender.trans() and Intl-based calls:
Facade::register('CustomTrans', \App\Services\HybridTranslator::class);
resources/lang/ar).trans() calls via deprecation warnings.Intl extension presence.composer.json constraints).spatie/laravel-translation-loader (duplicate translation loading).laravel-localization (locale detection middleware).Intl features).| Step | Task | Dependencies |
|---|---|---|
| 1 | Add package to composer.json |
None |
| 2 | Configure AppServiceProvider to bind IntlTranslator |
ext-intl enabled |
| 3 | Update config/app.php locale settings |
Existing app.locale |
| 4 | Test pluralization in views/APIs | Translation files |
| 5 | Replace trans() with translator()->get() in core logic |
Phase 1 validation |
| 6 | Deprecate old trans() calls |
Phase 2 complete |
binsoul/common-i18n-intl for updates (low activity = manual vetting).Intl-specific errors (e.g., MissingResourceException) may require deep PHP knowledge.ext-intl is enabled in staging/prod.IntlDateFormatter::format() failures will need locale-specific troubleshooting.ext-intl in Docker (docker-php-ext-install intl).und pseudo-locale).IntlTranslator level (Laravel’s cache system can be used).Intl in hot paths (e.g., cache pluralized strings in Redis).localizations table is indexed for locale and key.| Scenario | Impact | Mitigation |
|---|---|---|
ext-intl disabled |
Translations fail silently or throw errors | Fallback to simple trans() with deprecation warning |
| Missing translation keys | MissingResourceException |
Laravel’s default fallback chain (e.g., en → es) |
| Locale-specific bugs (e.g., Arabic RTL) | UI rendering issues | Test with native speakers; use IntlBreakIterator for edge cases |
| Package abandonment | No updates/security patches | Fork and maintain internally |
translator()->get('key')).trans() to hybrid system.Intl internals (e.g., IntlMessageFormatter).How can I help you explore Laravel packages today?