PHPackages                             sokil/php-isocodes - 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. sokil/php-isocodes

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

sokil/php-isocodes
==================

ISO country, subdivision, language, currency and script definitions and their translations. Based on pythons pycountry and Debian's iso-codes.

4.4.0(8mo ago)1812.2M—7.3%14[11 issues](https://github.com/sokil/php-isocodes/issues)12MITPHPPHP &gt;=7.4CI passing

Since Jul 20Pushed 8mo ago4 watchersCompare

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

READMEChangelog (10)Dependencies (8)Versions (63)Used By (12)

Stand With Ukraine 🇺🇦
=====================

[](#stand-with-ukraine-)

[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

---

PHP ISO Codes
=============

[](#php-iso-codes)

[![Continuous integration](https://github.com/sokil/php-isocodes/workflows/Continuous%20integration/badge.svg?branch=4.0)](https://github.com/sokil/php-isocodes/actions?query=workflow%3A%22Continuous+integration%22)[![Latest Stable Version](https://camo.githubusercontent.com/fde5976b4afb0f72f473de698dbe55e8b41785c74cce562aceb7683563e863c8/68747470733a2f2f706f7365722e707567782e6f72672f736f6b696c2f7068702d69736f636f6465732f762f737461626c652e706e673f31)](https://packagist.org/packages/sokil/php-isocodes)[![Coverage Status](https://camo.githubusercontent.com/752c9f1c078e3d7dc52de5fffc838f86441c8e49f6385d2bbc95c50f2de67d47/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f736f6b696c2f7068702d69736f636f6465732f62616467652e706e67)](https://coveralls.io/r/sokil/php-isocodes)[![Total Downloads](https://camo.githubusercontent.com/2767dee3f5f7b768fd7efdaa12c78e33b0cd4ac1335dc8059134c7d1f3124965/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f6b696c2f7068702d69736f636f6465732e7376673f31)](https://packagist.org/packages/sokil/php-isocodes)[![Daily Downloads](https://camo.githubusercontent.com/76398b44181ef819f38e5fa9866ce7c8b765ec7efb182091462314bef7177ddd/68747470733a2f2f706f7365722e707567782e6f72672f736f6b696c2f7068702d69736f636f6465732f642f6461696c79)](https://packagist.org/packages/sokil/php-isocodes/stats)

⭐ This library used to get localized names of countries, currencies, languages and scripts.

📦 Based on Python's [pycountry](https://pypi.python.org/pypi/pycountry) and Debian's [iso-codes](https://salsa.debian.org/iso-codes-team/iso-codes.git).

👅 Current translation status:

Table of contents
-----------------

[](#table-of-contents)

- [ISO Standards](#iso-standards)
- [Installation](#installation)
- [Translation drivers](#translation-drivers)
    - [Gettext extension driver](#gettext-extension-driver)
        - [Locale configuration](#locale-configuration)
    - [Symfony Translation driver](#symfony-translation-driver)
    - [Dummy driver](#dummy-driver)
- [Usage](#usage)
    - [Locale configuration](#locale-configuration)
    - [Countries database (ISO 3166-1)](#countries-database-iso-3166-1)
    - [Subdivisions database (ISO 3166-2)](#subdivisions-database-iso-3166-2)
    - [Historic countries database (ISO 3166-3)](#historic-countries-database-iso-3166-3)
    - [Scripts database (ISO 15924)](#scripts-database-iso-15924)
    - [Currencies database (ISO 4217)](#currencies-database-iso-4217)
    - [Languages database (ISO 639-3)](#languages-database-iso-639-3)
- [Tests](#tests)

ISO Standards
-------------

[](#iso-standards)

- **ISO 3166-1**: Country codes (alpha-2, alpha-3, numeric)
- **ISO 3166-2**: Principal subdivisions (e.g., provinces or states) of all countries coded in ISO 3166-1
- **ISO 3166-3**: Historic countries (alpha-2, alpha-3, alpha-4, numeric)
- **ISO 15924**: Scripts
- **ISO 4217**: Currencies
- **ISO 639-3**: Languages

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

[](#installation)

You may use this library in different modes:

- `sokil/php-isocodes` (this library) - install library without database and messages and setup periodic updates of database and messages by yourself with cron or inside CI/CD pipeline with `./bin/update_iso_codes_db.sh`
- [sokil/php-isocodes-db-only](https://github.com/sokil/php-isocodes-db-only) - if you do not need internationalisation, use this library. Database already inside. To update database just periodically update this library.
- [sokil/php-isocodes-db-i18n](https://github.com/sokil/php-isocodes-db-i18n) - if you need internationalisation, use this library. Database and messages already inside. To update database just periodically update this library.

#### 💾 Library with included database and localization

[](#-library-with-included-database-and-localization)

To install [library with database and i18n](https://github.com/sokil/php-isocodes-db-i18n):

[![Latest Stable Version](https://camo.githubusercontent.com/d3a17e96173a0a1ce572196777ff9c2a52b00ea84c2bbe500a5e85dd422643ad/68747470733a2f2f706f7365722e707567782e6f72672f736f6b696c2f7068702d69736f636f6465732d64622d6931386e2f762f737461626c652e706e67)](https://packagist.org/packages/sokil/php-isocodes-db-i18n)[![Total Downloads](https://camo.githubusercontent.com/3e429ce0c9a143e94e8ff4c39b816b99beb7263567f14da82e0c71de1d051355/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f6b696c2f7068702d69736f636f6465732d64622d6931386e2e7376673f31)](https://packagist.org/packages/sokil/php-isocodes-db-i18n)[![Daily Downloads](https://camo.githubusercontent.com/dba02a5a75e6721643cdb8ed256d85ca362c9f58668092c949c7dd062761f6cf/68747470733a2f2f706f7365722e707567782e6f72672f736f6b696c2f7068702d69736f636f6465732d64622d6931386e2f642f6461696c79)](https://packagist.org/packages/sokil/php-isocodes-db-i18n/stats)

```
composer require sokil/php-isocodes-db-i18n

```

#### 💾 Library with included database and without localization

[](#-library-with-included-database-and-without-localization)

You may also install [library with only database](https://github.com/sokil/php-isocodes-db-only) (no i18n will be available):

[![Latest Stable Version](https://camo.githubusercontent.com/f84a3f026abdec49d556fe76277b3a915c81c0055fe4ba4f270351e12acd73ba/68747470733a2f2f706f7365722e707567782e6f72672f736f6b696c2f7068702d69736f636f6465732d64622d6f6e6c792f762f737461626c652e706e67)](https://packagist.org/packages/sokil/php-isocodes-db-only)[![Total Downloads](https://camo.githubusercontent.com/507579834dab62733620361e59aed6ead6956a19a720dd64c210982be4b062b6/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f6b696c2f7068702d69736f636f6465732d64622d6f6e6c792e7376673f31)](https://packagist.org/packages/sokil/php-isocodes-db-only)[![Daily Downloads](https://camo.githubusercontent.com/595211823a63a4db2da1e914b7c53c62525a5a2c0b8b9ec77dc409eee351bc0a/68747470733a2f2f706f7365722e707567782e6f72672f736f6b696c2f7068702d69736f636f6465732d64622d6f6e6c792f642f6461696c79)](https://packagist.org/packages/sokil/php-isocodes-db-only/stats)

```
composer require sokil/php-isocodes-db-only

```

#### 💾 Library without database and localization, requires manual database installation and updates

[](#-library-without-database-and-localization-requires-manual-database-installation-and-updates)

You can install library through Composer:

```
composer require sokil/php-isocodes

```

Database and gettext files located in related packages inside `databases` and `messages` directories. This packages periodically updated with package version increment.

If you want to update database, use script `./bin/update_iso_codes_db.sh`. Call this script by cron, during deploy process or when build your docker image.

```
./bin/update_iso_codes_db.sh {mode} {base_dir} {build_dir}

```

ArgumentRequiredDescriptionmodeRequiredMay be "all" or "db\_only". In "all" mode update database (json files) and locallisation (po and mo files), in "db\_only" only database will updatebase\_dirRequiredDir where to place database and messagesbuild\_dirOptional. Default: "/tmp/iso-codes-build"Dir where source directory cloned and files original files processed.Now you need to configure factory to use this directory:

```
