PHPackages                             countlang/countlang - 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. countlang/countlang

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

countlang/countlang
===================

PHP library for the Unicode CLDR project

v1.0.0(8y ago)017MITPHPPHP &gt;=5.6.0

Since Jul 13Pushed 8y agoCompare

[ Source](https://github.com/countlang/countlang)[ Packagist](https://packagist.org/packages/countlang/countlang)[ RSS](/packages/countlang-countlang/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

CountLang
=========

[](#countlang)

[![Release](https://camo.githubusercontent.com/ad7ac49ddb0720085e8f71c272a07cb5baf61c77373f6942379916c4c4d46f77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f756e746c616e672f636f756e746c616e672e737667)](https://packagist.org/packages/countlang/countlang)[![Build Status](https://camo.githubusercontent.com/173f0207f152ca53ef3dfb39b3fe73980d72430e689448d1acb44148ef93dcb2/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f756e746c616e672f636f756e746c616e672f6d61737465722e737667)](http://travis-ci.org/countlang/countlang)[![Code Coverage](https://camo.githubusercontent.com/6efce7b136053e0bb313e9dee30191f9175c583b06bb1257ba852edc7dbe005b/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f636f756e746c616e672f636f756e746c616e672f6d61737465722e737667)](https://coveralls.io/r/countlang/countlang)[![License](https://camo.githubusercontent.com/6786027b8088bbeff7b556a19a9b057b7505e1b17c3bb23ef5934b9a43d02d8d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f756e746c616e672f636f756e746c616e672e737667)](https://raw.githubusercontent.com/countlang/countlang/master/LICENSE)

CountLang is a PHP library for the [Unicode CLDR](http://cldr.unicode.org) project.

Summary
-------

[](#summary)

The library provides data for any country, language, currency, region, sub-region and relationship between them.

Country is the base entity of CountLang. Language, currency, region and sub-region are independent entities, but they are all connected through the country.

Connection between entities is provided by a map of relations that binds the country with other entities.

Data is available for all countries that existed since 1974 (year of first issue of ISO 3166).

Doctrine cache is used to improve data parsing and mapping.

Installing
----------

[](#installing)

The easiest way to install this package is with [Composer](https://getcomposer.org) using the following command:

```
$ composer require countlang/countlang

```

Examples
--------

[](#examples)

Include composer loader and use library interface:

```
// include composer autoloader if you haven't done it yet
require __DIR__ . '/vendor/autoload.php';

// include library interface
use CountLang\CountLang;

// initialize CountLand interface
$countLang = new CountLang();
```

#### Country

[](#country)

```
// get a collection with all countries
$allCountries = $countlang->getCountries();
// get a list of all official country names
$allCountryNames = $allCountries->select('officialName');

// get the country entity of Denmark
$denmark = $countlang->getCountry('Denmark');

// get a collection of countries that share common border with Denmark
$denmarkNeigbors = $denmark->getBordersCollection();

// get a collection with all languages of Denmark
$denmarkLanguages = $denmark->getLanguagesCollection();
// get usage percentage of Danish language in Denmark
$usagePercentageOfDanishLanguageInDenmark = $denmarkLanguages->findEntity('Danish')->getUsagePercentage();

// get first currency entity from collection of Denmark's currencies
$denmarkCurrency = $denmark->getCurrenciesCollection()->getEntity();

// get name of Denmark's sub-region
$denmarkSubRegion = $denmark->getSubRegionEntity()->getName();

// get code of region Denmark is belong to
$denmarkRegion = $denmark->getRegionEntity()->getCode();
```

#### Language

[](#language)

```
// get a collection of all languages
$allLanguages = $countlang->getLanguages();
// get a list of alpha 3T codes (according to ISO 639) for all languages
$allLanguagesCodes = $allLanguages->select('alpha3TCode');

// get the language entity of Danish
$danishLanguage = $countlang->getLanguage('Danish');

// get a collection with all Danish-speaking countries entities
$danishLanguageCountries = $danishLanguage->getCountriesCollection();
// get a collection with all Danish-speaking countries
// that have a population more than half a million people
$mostPopulatedDanishLanguageCountries = $danishLanguageCountries->filter('population', 500000, 'gt');
// get a collection with all Danish-speaking countries
// that have a population less than 100 thousand people
// and have access to the world's ocean
$filteredDanishLanguageCountries = $danishLanguageCountries->multiFilter([
    ['population', 100000, CountLang\Filter\Filter::OPERATOR_LT],
    ['isLandLocked', false],
]);
```

#### Currency

[](#currency)

```
// get a collection of all currencies
$allCurrencies = $countlang->getCurrencies();
// get an associative array with official names and symbols of all countries
$allCurrenciesNamesAndSymbols = $allCurrencies->select(['officialName', 'symbol']);

// get the currency entity of Danish Krone
$danishKrona = $countlang->getCurrency('Danish Krone');

// get a collection of all countries that use Danish Krone
$danishKronaCountries = $danishKrona->getCountriesCollection();
```

#### Region

[](#region)

```
// get a collection of all regions
$allRegions = $countlang->getRegions();
// print the collection (in JSON format)
// Note: when used as a string, collection or entity will be converted to JSON
echo $allRegions;

// get the region entity of Europe
$europe = $countlang->getRegion('Europe');

// get a collection of European countries
$europeanCountries = $europe->getCountriesCollection();

// get a collection of Europe sub-regions
$subRegions = $europe->getSubRegionsCollection();
```

#### SubRegion

[](#subregion)

```
// get a collection of all sub-regions
$allSubRegions = $countlang->getSubRegions();
// get an associative array with complete data for all sub-regions
$allSubRegionsData = $allSubRegions->select();

// get the region entity of Northern Europe
$northernEurope = $countlang->getSubRegion('Northern Europe');

// get the region entity of Europe
$europe = $northernEurope->getRegionEntity();

// get the number of countries in the Northern Europe sub-region
$northernEuropeanCountriesAmount = $northernEurope->getCountriesCollection()->count();
```

Sources
-------

[](#sources)

The main source of data is the most recent release of [Unicode CLDR](http://cldr.unicode.org). Additionally used [ISO 3166](https://www.iso.org/iso-3166-country-codes.html), [ISO 639](https://www.iso.org/iso-639-language-codes.html), [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html), [World Bank Open Data](http://data.worldbank.org), [The World Factbook](https://www.cia.gov/library/publications/the-world-factbook), [Wikipedia](https://www.wikipedia.org), [WTNG](http://www.wtng.info).

License
-------

[](#license)

This library is available under the [MIT license](LICENSE).

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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

3274d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9068a7cd97b822051d54acd97ea955a0a46995bd7f36cb61e77c43dfa1218f86?d=identicon)[countlang](/maintainers/countlang)

---

Top Contributors

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

---

Tags

currencylanguagecldrISO 3166countryregionISO 4217iso-639

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[gettext/languages

gettext languages with plural rules

7832.7M12](/packages/gettext-languages)[codezero/laravel-localized-routes

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

544656.8k4](/packages/codezero-laravel-localized-routes)[codezero/laravel-localizer

Automatically detect and set an app locale that matches your visitor's preference.

50404.9k4](/packages/codezero-laravel-localizer)[tigrov/yii2-country

Country data for Yii2 using Intl extension and more.

151.1k](/packages/tigrov-yii2-country)[icanboogie/cldr

Localize applications using Unicode's CLDR

47250.2k3](/packages/icanboogie-cldr)[codezero/browser-locale

Get the most preferred locales from your visitor's browser.

161.9M17](/packages/codezero-browser-locale)

PHPackages © 2026

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