PHPackages                             koenster/php-language-detection - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. koenster/php-language-detection

AbandonedArchivedProject[Localization &amp; i18n](/categories/localization)

koenster/php-language-detection
===============================

Detects the preferred language from the browser and compares this with the available languages/locales to return the best language/locale to redirect.

v1.0.4(9y ago)445.6k↓62.6%11MITPHPPHP &gt;=5.5.9

Since Apr 25Pushed 9y ago3 watchersCompare

[ Source](https://github.com/Koenster/php-language-detection)[ Packagist](https://packagist.org/packages/koenster/php-language-detection)[ RSS](/packages/koenster-php-language-detection/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (1)

PHP localization / language detection script
============================================

[](#php-localization--language-detection-script)

Detects the preferred language from the browser and compares this with the available languages/locales to return the best language/locale to redirect.

How to install
--------------

[](#how-to-install)

```
composer require koenster/php-language-detection

```

How to use
----------

[](#how-to-use)

```

use koenster\PHPLanguageDetection\BrowserLocalization;

$browser = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$default = 'nl-NL';
$available = ['nl-NL', 'nl-BE', 'en-GB', 'fr-FR'];

$browser = new BrowserLocalization();

$browser->setAvailable($available)
    ->setDefault($default)
    ->setPreferences($browser);

// Will return or a default or when available, the available locale.
echo $browser->detect();

```

\##License

This Language Detection script is open-sourced software licensed under the MIT license.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Total

5

Last Release

3570d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1be7c9e9c7ecf7fb69443d02d3bf54c9fc5d17194ef0439a861344ddc19fadbd?d=identicon)[Koenster](/maintainers/Koenster)

---

Top Contributors

[![Koenster](https://avatars.githubusercontent.com/u/8639159?v=4)](https://github.com/Koenster "Koenster (7 commits)")[![sirdiego](https://avatars.githubusercontent.com/u/118378?v=4)](https://github.com/sirdiego "sirdiego (2 commits)")

---

Tags

php language detectionbrowser localization detectionbrowser localisation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/koenster-php-language-detection/health.svg)

```
[![Health](https://phpackages.com/badges/koenster-php-language-detection/health.svg)](https://phpackages.com/packages/koenster-php-language-detection)
```

###  Alternatives

[smarty-gettext/smarty-gettext

Gettext plugin enabling internationalization in Smarty Package files

752.5M8](/packages/smarty-gettext-smarty-gettext)[devaslanphp/auto-translate

Auto generate translation JSON files

6627.3k](/packages/devaslanphp-auto-translate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
