PHPackages                             xdg/locale - 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. xdg/locale

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

xdg/locale
==========

PHP library to work with POSIX locale identifiers.

0.1.0(3y ago)074MITPHPPHP &gt;=8.1

Since Oct 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/php-xdg/locale)[ Packagist](https://packagist.org/packages/xdg/locale)[ RSS](/packages/xdg-locale/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

xdg/locale
==========

[](#xdglocale)

[![codecov](https://camo.githubusercontent.com/4f6e62b30be1f1a0c463da59f28fe636a76f4901e3393e63b7038009af3844e0/68747470733a2f2f636f6465636f762e696f2f67682f7068702d7864672f6c6f63616c652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d5145363732554b325a47)](https://codecov.io/gh/php-xdg/locale)

PHP library to work with POSIX locale identifiers.

Installation
------------

[](#installation)

```
composer require xdg/locale
```

Usage
-----

[](#usage)

### Constructing locale objects

[](#constructing-locale-objects)

```
use Xdg\Locale\Locale;

// from a POSIX locale identifier
$locale = Locale::of('ca_ES@valencia');
// from an IETF (BCP47) language tag
$locale = Locale::of('zh-Hans-CN');
// On Windows, windows-specific locale identifiers are accepted
$locale = Locale::of('French_France.1252');
```

### Locale matching

[](#locale-matching)

Locale matching is performed using the algorithm described in the [XDG Desktop Entry specification](https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#idm46403733864464).

```
use Xdg\Locale\Locale;

$locale = Locale::of('fr_FR.UTF-8')
$locale->matches('fr'); // => true
$locale->matches('fr_BE'); // => false
```

Use `Locale::select()` to select the best match from a list of candidates.

```
use Xdg\Locale\Locale;

$locale = Locale::of('fr_FR.UTF-8')
$locale->select(['fr_CA', 'fr_BE', 'fr']); // => 'fr'
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1313d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db8c537fa479fd389b9ef832345ebf665f767e3ff7c7c345bc0ba4c52b46a22f?d=identicon)[ju1ius](/maintainers/ju1ius)

---

Top Contributors

[![ju1ius](https://avatars.githubusercontent.com/u/218404?v=4)](https://github.com/ju1ius "ju1ius (7 commits)")

---

Tags

freedesktoplocaleposixxdgposixlocalefreedesktopxdg

### Embed Badge

![Health badge](/badges/xdg-locale/health.svg)

```
[![Health](https://phpackages.com/badges/xdg-locale/health.svg)](https://phpackages.com/packages/xdg-locale)
```

###  Alternatives

[fightbulc/moment

Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

9693.2M10](/packages/fightbulc-moment)[codemix/yii2-localeurls

Automatic locale/language management for URLs.

4071.3M30](/packages/codemix-yii2-localeurls)[codezero/laravel-localized-routes

A convenient way to set up, manage and use localized routes in a Laravel app.

543638.1k4](/packages/codezero-laravel-localized-routes)[aplus/language

Aplus Framework Language Library

2351.7M15](/packages/aplus-language)[vanderlee/syllable

Text syllable splitting and hyphenation using Frank M. Liang's TeX algorithm.

124432.6k8](/packages/vanderlee-syllable)[tractorcow/silverstripe-fluent

Simple localisation for Silverstripe

92421.6k26](/packages/tractorcow-silverstripe-fluent)

PHPackages © 2026

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