PHPackages                             commerceguys/intl - 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. commerceguys/intl

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

commerceguys/intl
=================

Internationalization library powered by CLDR data.

v2.0.7(1y ago)36810.0M—8.2%44[8 issues](https://github.com/commerceguys/intl/issues)[2 PRs](https://github.com/commerceguys/intl/pulls)20MITPHPPHP &gt;=8.0CI passing

Since Feb 23Pushed 1y ago14 watchersCompare

[ Source](https://github.com/commerceguys/intl)[ Packagist](https://packagist.org/packages/commerceguys/intl)[ RSS](/packages/commerceguys-intl/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (31)Used By (20)

intl
====

[](#intl)

[![Build Status](https://github.com/commerceguys/intl/actions/workflows/build.yml/badge.svg)](https://github.com/commerceguys/intl/actions/workflows/build.yml)

A PHP 8.0+ internationalization library, powered by CLDR data.

Features:

- NumberFormatter and CurrencyFormatter, inspired by [intl](http://php.net/manual/en/class.numberformatter.php).
- Currencies
- Languages

Looking for a list of countries and subdivisions? Check out [commerceguys/addressing](https://github.com/commerceguys/addressing).

Why not use the intl extension?
-------------------------------

[](#why-not-use-the-intl-extension)

The intl extension isn't present by default on PHP installs, requiring it can hurt software adoption. Behind the scenes the extension relies on libicu which includes the CLDR dataset, but depending on the OS/distribution used, could be several major CLDR releases behind.

Since the CLDR dataset is freely available in JSON form, it is possible to reimplement the intl functionality in pure PHP code while ensuring that the dataset is always fresh.

Having access to the CLDR dataset also makes it possible to offer additional APIs, such as listing all currencies.

More backstory can be found in [this blog post](https://drupalcommerce.org/blog/15916/commerce-2x-stories-internationalization).

Formatting numbers
------------------

[](#formatting-numbers)

Allows formatting numbers (decimals, percents, currency amounts) using locale-specific rules.

Two formatters are provided for this purpose: [NumberFormatter](https://github.com/commerceguys/intl/blob/master/src/Formatter/NumberFormatterInterface.php) and [CurrencyFormatter](https://github.com/commerceguys/intl/blob/master/src/Formatter/CurrencyFormatterInterface.php).

```
use CommerceGuys\Intl\Currency\CurrencyRepository;
use CommerceGuys\Intl\NumberFormat\NumberFormatRepository;
use CommerceGuys\Intl\Formatter\NumberFormatter;
use CommerceGuys\Intl\Formatter\CurrencyFormatter;

$numberFormatRepository = new NumberFormatRepository;
// Options can be provided to the constructor or the
// individual methods, the locale defaults to 'en' when missing.
$numberFormatter = new NumberFormatter($numberFormatRepository);
echo $numberFormatter->format('1234.99'); // 1,234.99
echo $numberFormatter->format('0.75', ['style' => 'percent']); // 75%

$currencyRepository = new CurrencyRepository;
$currencyFormatter = new CurrencyFormatter($numberFormatRepository, $currencyRepository);
echo $currencyFormatter->format('2.99', 'USD'); // $2.99
// The accounting style shows negative numbers differently and is used
// primarily for amounts shown on invoices.
echo $currencyFormatter->format('-2.99', 'USD', ['style' => 'accounting']); // (2.99$)

// Arabic, Arabic extended, Bengali, Devanagari digits are supported as expected.
$currencyFormatter = new CurrencyFormatter($numberFormatRepository, $currencyRepository, ['locale' => 'ar']);
echo $currencyFormatter->format('1230.99', 'USD'); // US$ ١٬٢٣٠٫٩٩

// Parse formatted values into numeric values.
echo $currencyFormatter->parse('US$ ١٬٢٣٠٫٩٩', 'USD'); // 1230.99
```

Currencies
----------

[](#currencies)

```
use CommerceGuys\Intl\Currency\CurrencyRepository;

// Reads the currency definitions from resources/currency.
$currencyRepository = new CurrencyRepository;

// Get the USD currency using the default locale (en).
$currency = $currencyRepository->get('USD');
echo $currency->getCurrencyCode(); // USD
echo $currency->getNumericCode(); // 840
echo $currency->getFractionDigits(); // 2
echo $currency->getName(); // US Dollar
echo $currency->getSymbol(); // $
echo $currency->getLocale(); // en

// Get the USD currency using the fr-FR locale.
$currency = $currencyRepository->get('USD', 'fr-FR');
echo $currency->getName(); // dollar des États-Unis
echo $currency->getSymbol(); // $US
echo $currency->getLocale(); // fr-FR

// Get all currencies, keyed by currency code.
$allCurrencies = $currencyRepository->getAll();
```

Languages
---------

[](#languages)

```
use CommerceGuys\Intl\Language\LanguageRepository;

// Reads the language definitions from resources/language.
$languageRepository = new LanguageRepository;

// Get the german language using the default locale (en).
$language = $languageRepository->get('de');
echo $language->getLanguageCode(); // de
echo $language->getName(); // German

// Get the german language using the fr-FR locale.
$language = $languageRepository->get('de', 'fr-FR');
echo $language->getName(); // allemand

// Get all languages, keyed by language code.
$allLanguages = $languageRepository->getAll();
```

Related projects
----------------

[](#related-projects)

[Laravel integration](https://github.com/Propaganistas/Laravel-Intl/)

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance46

Moderate activity, may be stable

Popularity65

Solid adoption and visibility

Community41

Growing community involvement

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 75.7% 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 ~132 days

Recently: every ~181 days

Total

29

Last Release

403d ago

Major Versions

v0.7.5 → v1.0.02018-05-28

v1.1.2 → v2.0.02023-03-02

PHP version history (6 changes)v0.5PHP &gt;=5.4.0

v1.0.0PHP &gt;=5.5.0

v1.0.6PHP &gt;=7.0.8

v1.1.0PHP &gt;=7.1.3

v1.1.2PHP &gt;=7.3

v2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/621c34dbc1ad3ea00e09f6006aa9607d0046bf862182d59c66f1f18cb51c0f15?d=identicon)[bojanz](/maintainers/bojanz)

![](https://www.gravatar.com/avatar/86a6bdd58eca36ebbb80ea79ca7ab3e6d870377453a3a7a867c85cd929e1492f?d=identicon)[jsacksick](/maintainers/jsacksick)

---

Top Contributors

[![bojanz](https://avatars.githubusercontent.com/u/330162?v=4)](https://github.com/bojanz "bojanz (153 commits)")[![jsacksick](https://avatars.githubusercontent.com/u/1007558?v=4)](https://github.com/jsacksick "jsacksick (26 commits)")[![StryKaizer](https://avatars.githubusercontent.com/u/2759806?v=4)](https://github.com/StryKaizer "StryKaizer (6 commits)")[![Jbekker](https://avatars.githubusercontent.com/u/930668?v=4)](https://github.com/Jbekker "Jbekker (4 commits)")[![limenet](https://avatars.githubusercontent.com/u/474329?v=4)](https://github.com/limenet "limenet (2 commits)")[![joshbrw](https://avatars.githubusercontent.com/u/779766?v=4)](https://github.com/joshbrw "joshbrw (1 commits)")[![marcortola](https://avatars.githubusercontent.com/u/15958009?v=4)](https://github.com/marcortola "marcortola (1 commits)")[![mglaman](https://avatars.githubusercontent.com/u/3698644?v=4)](https://github.com/mglaman "mglaman (1 commits)")[![Propaganistas](https://avatars.githubusercontent.com/u/6680176?v=4)](https://github.com/Propaganistas "Propaganistas (1 commits)")[![qzmenko](https://avatars.githubusercontent.com/u/6370089?v=4)](https://github.com/qzmenko "qzmenko (1 commits)")[![arubacao](https://avatars.githubusercontent.com/u/7462542?v=4)](https://github.com/arubacao "arubacao (1 commits)")[![Vishalghyv](https://avatars.githubusercontent.com/u/43421881?v=4)](https://github.com/Vishalghyv "Vishalghyv (1 commits)")[![borisson](https://avatars.githubusercontent.com/u/1721156?v=4)](https://github.com/borisson "borisson (1 commits)")[![boywijnmaalen](https://avatars.githubusercontent.com/u/3985741?v=4)](https://github.com/boywijnmaalen "boywijnmaalen (1 commits)")[![fbonzon](https://avatars.githubusercontent.com/u/1116761?v=4)](https://github.com/fbonzon "fbonzon (1 commits)")[![greatislander](https://avatars.githubusercontent.com/u/605361?v=4)](https://github.com/greatislander "greatislander (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/commerceguys-intl/health.svg)

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

###  Alternatives

[joedixon/laravel-translation

A tool for managing all of your Laravel translations

717911.4k11](/packages/joedixon-laravel-translation)[illuminate/translation

The Illuminate Translation package.

6936.4M495](/packages/illuminate-translation)[lajax/yii2-translate-manager

Translation management extension for Yii 2

227578.8k13](/packages/lajax-yii2-translate-manager)[larswiegers/laravel-translations-checker

Make sure your laravel translations are checked and are included in all languages.

256423.2k2](/packages/larswiegers-laravel-translations-checker)[inpsyde/multilingual-press

Simply THE multisite-based free open source plugin for your multilingual websites.

2414.0k1](/packages/inpsyde-multilingual-press)[statikbe/laravel-chained-translator

The Laravel Chained Translator can combine several translators that can override each others translations.

36149.4k6](/packages/statikbe-laravel-chained-translator)

PHPackages © 2026

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