codezero/browser-locale
Parse the browser’s Accept-Language header to get a visitor’s preferred locales in order. Returns primary locale or full locale list with language/region parts. Works in vanilla PHP and integrates with Laravel via the container.
nl-* locales"). Integrates with Laravel’s localization middleware or services like App::setLocale().$_SERVER["HTTP_ACCEPT_LANGUAGE"] (a common but error-prone task). Low-risk adoption due to MIT license and minimal dependencies..de for de-DE users).weight values (e.g., prioritize en-US over en-GB).fr-FR).es-ES → es).Adopt if:
HTTP_ACCEPT_LANGUAGE (handling edge cases like q values, duplicates, or malformed strings).Look elsewhere if:
For Executives: "This package lets us automatically serve content in a user’s preferred language based on their browser settings—no extra steps for them. For example, a visitor from Spain will see Spanish content by default, while someone from Brazil gets Portuguese. This reduces bounce rates for non-English users and aligns with our global expansion goals. It’s a lightweight, low-cost way to improve personalization without heavy development lift. The MIT license means no vendor lock-in, and it integrates seamlessly with our Laravel stack."
For Engineering:
*"This solves a common pain point: parsing $_SERVER['HTTP_ACCEPT_LANGUAGE'] correctly. The package handles:
q=0.8) to prioritize locales (e.g., en-US over en-GB).en-US,en).It’s battle-tested (PHP 7.0+), actively maintained (last release March 2024), and adds zero complexity to our stack. We can use it for:
Accept-Language headers).app()->setLocale().Trade-offs: Minimal—just a Composer install and a few lines of code. No database or external dependencies."*
How can I help you explore Laravel packages today?