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

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

phospr/locale
=============

A simple PHP Locale Value Object

v1.0.0(10y ago)12.0k1MITPHP &gt;=5.3.0

Since Mar 14Compare

[ Source](https://github.com/phospr/locale)[ Packagist](https://packagist.org/packages/phospr/locale)[ RSS](/packages/phospr-locale/feed)WikiDiscussions Synced yesterday

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

Phospr\\Locale
==============

[](#phosprlocale)

[![Build Status](https://camo.githubusercontent.com/4314d063e06ef71931cace260aabe1bb05ee0ad86891c2c4beb0e138e4741608/68747470733a2f2f7472617669732d63692e6f72672f70686f7370722f6c6f63616c652e737667)](https://travis-ci.org/phospr/locale)[![Coverage Status](https://camo.githubusercontent.com/507ec07110075b8b3212e65d20499b18e4fe78a4f71b0633f7ec8bb2d2310a22/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70686f7370722f6c6f63616c652f62616467652e737667)](https://coveralls.io/github/phospr/locale)

Simple PHP Locale ValueObject

Usage
-----

[](#usage)

```
use Phospr\Locale;

echo Locale::fromString('en_US'); // en_US
echo Locale::fromCountrySlashLanguage('ca/fr'); // fr_CA

```

### Formatting

[](#formatting)

Use:

- `%L` For uppercase language code
- `%l` For lowercase language code
- `%C` For uppercase country code
- `%c` For lowercase country code

Note:

- any other combination of %{:char:} will throw an InvalidArgumentException unless the % is escaped with \\
- to get a `\` You will need to double escape ( `\\\` )

Examples:

```
echo Locale::fromString('se_FI')->format('%L_%c'); // SE_fi
echo Locale::fromString('se_FI')->format('%C/%s'); // FI/se
echo Locale::fromString('se_FI')->format('%c/%s'); // fi/se
echo Locale::fromString('se_FI')->format('%c\\\%s'); // fi\se
```

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

[](#installation)

```
composer require phospr/locale

```

#### Sources

[](#sources)

Language data from

Country data from

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

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

3761d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f7a54fbc3ac6dfedf6fb7d34386c2d95aa9dae6c1ac706134b849a8ce5355e2?d=identicon)[tomhv](/maintainers/tomhv)

---

Top Contributors

[![imctomhv](https://avatars.githubusercontent.com/u/24391197?v=4)](https://github.com/imctomhv "imctomhv (7 commits)")[![tomhv](https://avatars.githubusercontent.com/u/301805?v=4)](https://github.com/tomhv "tomhv (6 commits)")[![imcctatro](https://avatars.githubusercontent.com/u/24417655?v=4)](https://github.com/imcctatro "imcctatro (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1926.6k1](/packages/smmoosavi-php-gettext)[laradevs/spanish

labels translated to spanish

166.7k](/packages/laradevs-spanish)

PHPackages © 2026

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