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

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

digitalrevolution/intl
======================

Digital Revolution Internationalization library

v1.8.0(8mo ago)337.4k↓30.6%9[1 issues](https://github.com/123inkt/internationalization/issues)[1 PRs](https://github.com/123inkt/internationalization/pulls)MITPHPPHP &gt;=8.1CI passing

Since Feb 24Pushed 3mo agoCompare

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

READMEChangelog (10)Dependencies (12)Versions (16)Used By (0)

[![Minimum PHP Version](https://camo.githubusercontent.com/230588f62e4b3ba29858fcfcf1bbfe253f82c4180088091d6c7d4c6c06d80145/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e312d383839324246)](https://php.net/)[![Run tests](https://github.com/123inkt/internationalization/workflows/Run%20checks/badge.svg)](https://github.com/123inkt/internationalization/workflows/Run%20checks/badge.svg)

Digital Revolution Internationalization
=======================================

[](#digital-revolution-internationalization)

Library to format Numbers, Dates, \\Money\\Money objects and currencies to string according to the locale.

Getting Started
---------------

[](#getting-started)

```
composer require digitalrevolution/intl
```

Usage
-----

[](#usage)

### NumberFormatService

[](#numberformatservice)

Format number and currencies

```
use DR\Internationalization\Currency\CurrencyFormatOptions;
use DR\Internationalization\Number\NumberFormatOptions;
use DR\Internationalization\NumberFormatService;
use Money\Money;

// set default configuration
$currencyOptions = (new CurrencyFormatOptions())
    ->setLocale('nl_NL')
    ->setCurrencyCode('EUR')
    ->setGrouping(false);
$numberOptions = (new NumberFormatOptions())
    ->setLocale('nl_NL')
    ->setDecimals(2)
    ->setTrimDecimals(true);
$service = new NumberFormatService($currencyOptions, $numberOptions);
```

Format currencies:

```
$service->currency(1500.5);
// output: € 1500,50

$service->currency(new Money('150050', new Currency('EUR')));
// output: € 1500,50

$service->currency(1500.5, (new CurrencyFormatOptions())->setGrouping(true));
// output: € 1.500,50
```

Format numbers:

```
$service->number(1500.5);
// output: 1500,50

$service->number(1500.5, (new NumberFormatOptions())->setGrouping(true));
// output: 1.500,50

$service->number(1500.0, (new NumberFormatOptions())->setTrimDecimals(NumberFormatOptions::TRIM_DECIMAL_ALL_OR_NOTHING));
// output: 1500

$service->number(1500.5, (new NumberFormatOptions())->setTrimDecimals(NumberFormatOptions::TRIM_DECIMAL_ALL_OR_NOTHING));
// output: 1500.50

$service->number(1500.5, (new NumberFormatOptions())->setTrimDecimals(NumberFormatOptions::TRIM_DECIMAL_ANY));
// output: 1500.5
```

### NumberParser

[](#numberparser)

Parse float number from string determining the user's input for thousands and decimals separator.

```
NumberParser::parseFloat('1050');
// output: 1050.0

NumberParser::parseFloat('1050.5');
// output: 1050.5

NumberParser::parseFloat('1050,5');
// output: 1050.5

NumberParser::parseFloat('1.050,5');
// output: 1050.5

NumberParser::parseFloat('1,050.5');
// output: 1050.5

NumberParser::parseFloat('1,000,050.5');
// output: 1000050.5
```

### DateFormatService

[](#dateformatservice)

Formats dates and times. Input can be timestamps, strings (compatible with strtotime) and DateTimeInterface objects.

Use the following for format: [https://unicode-org.github.io/icu/userguide/format\_parse/datetime/#date-field-symbol-table](https://unicode-org.github.io/icu/userguide/format_parse/datetime/#date-field-symbol-table)

```
$dateFormatOptions = new DateFormatOptions('nl_NL', date_default_timezone_get())
$dateFormatter = new DateFormatService($dateFormatOptions);

$dateFormatter->format(time(), 'eeee dd LLLL Y - HH:mm:ss');
// example output: zaterdag 02 juni 2040 - 05:57:02

$dateFormatter->format('next saturday', 'eeee dd LLLL Y - HH:mm:ss');
// example output: zaterdag 02 juni 2040 - 05:57:02

$dateFormatter->format(new DateTime(), 'eeee dd LLLL Y - HH:mm:ss');
// example output: zaterdag 02 juni 2040 - 05:57:02
```

It is also possible to format dates and times to relative dates, such as 'today' and 'tomorrow' The RelativeDateFormatOptions decides how many days ahead it will try to convert a date to a relative date.

```
$dateFormatOptions = new DateFormatOptions('nl_NL', date_default_timezone_get())
$dateFormatter = new DateFormatService($dateFormatOptions);

$dateFormatter->formatRelative(time(), 'Y-m-d', new RelativeDateFormatOptions(1));
// example output: Vandaag

$dateFormatter->formatRelative(new DateTime('+1 day'), 'Y-m-d', new RelativeDateFormatOptions(1);
// example output: Morgen

$dateFormatter->formatRelative(new DateTime('+2 days'), 'Y-m-d', new RelativeDateFormatOptions(2));
// example output: Overmorgen

$dateFormatter->formatRelative(new DateTime('-2 days'), 'Y-m-d', new RelativeDateFormatOptions(2));
// example output: Eergisteren

// This will not convert the date to a relative date, as the options limit it one day ahead. Instead, it formats the date to the given pattern.
$dateFormatter->formatRelative(new DateTime('+2 days'), 'Y-m-d', new RelativeDateFormatOptions(1));
// example output: 2024-01-03
```

### DayOfTheWeekFormatter

[](#dayoftheweekformatter)

Format the PHP Date day of the week to string

```
$formatter = new DayOfTheWeekFormatter('nl_NL');

$formatter->format(DayOfTheWeekFormatter::MONDAY);
// output: maandag

$formatter->format(DayOfTheWeekFormatter::MONDAY, 'en_US');
// output: Monday
```

### PhoneNumberFormatService

[](#phonenumberformatservice)

Format phoneNumbers

```
use DR\Internationalization\PhoneNumber\PhoneNumberFormatOptions;
use DR\Internationalization\PhoneNumberFormatService;

// set default configuration
$phoneNumberOptions = (new PhoneNumberFormatOptions())
    ->setDefaultCountryCode('NL')
    ->setFormat(PhoneNumberFormatOptions::FORMAT_INTERNATIONAL_DIAL);
$service = new PhoneNumberFormatService($phoneNumberOptions);

$service->format("+31612345678");
// output: 0031612345678

$service->format("0612345678");
// output: 0031612345678
```

### PhoneNumberParseService

[](#phonenumberparseservice)

```
use DR\Internationalization\PhoneNumberParseService;

$parseService = new PhoneNumberParseService("NL");
$parsedPhoneNumber = $parseService->parse("+31612345678");
```

Project structure
-----------------

[](#project-structure)

DirectoryDescriptionCurrencyFormat `int`, `float` or `Money` value to locale specific format. Use `NumberFormatService::currency`DateFormat ISO-8601 day of the week to user friendly namesMoneyCreate `Money` object from `float`NumberFormat `int` or `float` value to locale specific format. Use `NumberFormatService::number`PhoneNumberFormat phoneNumber value to specified format. Use `PhoneNumberFormatService::format`Development
-----------

[](#development)

### Run code quality checks:

[](#run-code-quality-checks)

`composer run check`

### Run unit tests:

[](#run-unit-tests)

`composer run test`

About us
--------

[](#about-us)

At 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP and our several shops. Do you want to join us? [We are looking for developers](https://www.werkenbij123inkt.nl/zoek-op-afdeling/it).

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance65

Regular maintenance activity

Popularity35

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 52.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 ~106 days

Recently: every ~69 days

Total

13

Last Release

262d ago

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v1.5.0PHP &gt;=8.1

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/20e2ae81f6cffdb8c1b1a488b7f2f70270a5d1bf2a57aae09950697ac0ef3dad?d=identicon)[123Tim](/maintainers/123Tim)

---

Top Contributors

[![frankdekker](https://avatars.githubusercontent.com/u/2179983?v=4)](https://github.com/frankdekker "frankdekker (57 commits)")[![123InktJules](https://avatars.githubusercontent.com/u/188312414?v=4)](https://github.com/123InktJules "123InktJules (17 commits)")[![kbosma123](https://avatars.githubusercontent.com/u/145757848?v=4)](https://github.com/kbosma123 "kbosma123 (11 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (8 commits)")[![bram123](https://avatars.githubusercontent.com/u/7457368?v=4)](https://github.com/bram123 "bram123 (8 commits)")[![123jkarssen](https://avatars.githubusercontent.com/u/111290543?v=4)](https://github.com/123jkarssen "123jkarssen (2 commits)")[![ronaldvandenbrink123inkt](https://avatars.githubusercontent.com/u/183507370?v=4)](https://github.com/ronaldvandenbrink123inkt "ronaldvandenbrink123inkt (2 commits)")[![LSparky](https://avatars.githubusercontent.com/u/10746515?v=4)](https://github.com/LSparky "LSparky (1 commits)")[![danny-janse](https://avatars.githubusercontent.com/u/3527340?v=4)](https://github.com/danny-janse "danny-janse (1 commits)")[![mkonstantinou123inkt](https://avatars.githubusercontent.com/u/116018579?v=4)](https://github.com/mkonstantinou123inkt "mkonstantinou123inkt (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/digitalrevolution-intl/health.svg)](https://phpackages.com/packages/digitalrevolution-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)
