PHPackages                             popphp/pop-i18n - 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. popphp/pop-i18n

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

popphp/pop-i18n
===============

Pop I18n Component for Pop PHP Framework

4.0.3(6mo ago)56.1k↓50%1BSD-3-ClausePHPPHP &gt;=8.3.0CI passing

Since Jul 21Pushed 6mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (23)Used By (1)

pop-i18n
========

[](#pop-i18n)

[![Build Status](https://github.com/popphp/pop-i18n/workflows/phpunit/badge.svg)](https://github.com/popphp/pop-i18n/actions)[![Coverage Status](https://camo.githubusercontent.com/f764ac35b310cd25b53ca86ea2865138e1dc8c12a2c1f55b57fdf18f27891446/687474703a2f2f63632e706f707068702e6f72672f636f7665726167652e7068703f636f6d703d706f702d6931386e)](http://cc.popphp.org/pop-i18n/)

[![Join the chat at https://discord.gg/TZjgT74U7E](https://camo.githubusercontent.com/acad7b0eeb78b78d08ffd2b85681ab243436388b5f86f8bcb956a69246e53739/68747470733a2f2f6d656469612e706f707068702e6f72672f696d672f646973636f72642e737667)](https://discord.gg/TZjgT74U7E)

- [Overview](#overview)
- [Install](#install)
- [Quickstart](#quickstart)
- [Advanced](#advanced)

Overview
--------

[](#overview)

`pop-i18n` is a component for internationalization and localization. It provides the features for translating and managing different languages and locales that may be required for an application. It also provides for parameters to be injected into the text for personalization.

`pop-i18n` is a component of the [Pop PHP Framework](https://www.popphp.org/).

[Top](#pop-i18n)

Install
-------

[](#install)

Install `pop-i18n` using Composer.

```
composer require popphp/pop-i18n

```

Or, require it in your composer.json file

```
"require": {
    "popphp/pop-i18n" : "^4.0.3"
}

```

[Top](#pop-i18n)

Quickstart
----------

[](#quickstart)

First, you will have to create your language and locale files. The accepted formats are either XML or JSON:

##### fr.xml

[](#frxml)

```

DOCTYPE language [

        ]>

            Hello, my name is %1. I love to program %2.
            Bonjour, mon nom est %1. Je aime programmer %2.

```

##### fr.json

[](#frjson)

```
{
    "language"  : {
        "src"    : "en",
        "output" : "fr",
        "name"   : "French",
        "native" : "Français",
        "locale" : [{
            "region" : "FR",
            "name"   : "France",
            "native" : "France",
            "text"   : [
                {
                    "source" : "Hello, my name is %1. I love to program %2.",
                    "output" : "Bonjour, mon nom est %1. Je aime programmer %2."
                }
            ]
        }]
    }
}
```

From there, you can create your I18n object and give it the folder with the language files in it. It will auto-detect which file to load based on the language passed.

```
use Pop\I18n\I18n;

$lang = new I18n('fr_FR', '/path/to/language/files');

$string = $lang->__('Hello, my name is %1. I love to program %2.', ['Nick', 'PHP']);
echo $string;
```

```
Bonjour, mon nom est Nick. Je aime programmer PHP.

```

Alternatively, you can directly echo the string out like this:

```
$lang->_e('Hello, my name is %1. I love to program %2.', ['Nick', 'PHP']);
```

You can set the language and locale when you instantiate the I18n object like above, or if you prefer, you can set it in your application as a constant `POP_LANG` and the I18n object will look for that as well. The default is `en_US`.

[Top](#pop-i18n)

Advanced
--------

[](#advanced)

The `pop-i18n` component comes with the functionality to assist you in generating your required language files. Knowing the time and possibly money required to translate your application's text into multiple languages, the component can help with assembling the language files once you have the content.

You can give it arrays of data to generate complete files:

```
use Pop\I18n\Format;

$lang = [
    'src'    => 'en',
    'output' => 'de',
    'name'   => 'German',
    'native' => 'Deutsch'
];

$locales = [
    [
        'region' => 'DE',
        'name'   => 'Germany',
        'native' => 'Deutschland',
        'text' => [
            [
                'source' => 'This field is required.',
                'output' => 'Dieses Feld ist erforderlich.'
            ],
            [
                'source' => 'Please enter your name.',
                'output' => 'Bitte geben Sie Ihren Namen ein.'
            ]
        ]
    ]
];

// Create the XML format
Format\Xml::createFile($lang, $locale, '/path/to/language/files/de.xml');

// Create in JSON format
Format\Json::createFile($lang, $locale, '/path/to/language/files/de.json');
```

Also, if you have a source text file and an output text file with a 1:1 line-by-line ratio, then you can create the language files in fragment set and merge them as needed. An example of a 1:1 ratio source-to-output text files:

source/en.txtoutput/de.txtThis field is required.Dieses Feld ist erforderlich.Please enter your name.Bitte geben Sie Ihren Namen ein.So then, you can do this:

```
use Pop\I18n\Format;

// Create the XML format fragment
Format\Xml::createFragment('source/en.txt', 'output/de.txt', '/path/to/files/');

// Create the JSON format fragment
Format\Json::createFragment('source/en.txt', 'output/de.txt', '/path/to/files/');
```

And merge the fragments into a main language file.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance67

Regular maintenance activity

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 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

Every ~234 days

Recently: every ~269 days

Total

17

Last Release

194d ago

Major Versions

2.1.0p2 → 3.0.02017-09-14

3.2.1 → 4.0.02023-11-09

PHP version history (8 changes)2.0.0PHP &gt;=5.4.0

3.0.0PHP &gt;=5.6.0

3.0.2PHP &gt;=7.1.0

3.2.0PHP &gt;=7.3.0

3.2.1PHP &gt;=7.4.0

4.0.0PHP &gt;=8.1.0

4.0.1PHP &gt;=8.2.0

4.0.3PHP &gt;=8.3.0

### Community

Maintainers

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

---

Top Contributors

[![nicksagona](https://avatars.githubusercontent.com/u/898670?v=4)](https://github.com/nicksagona "nicksagona (32 commits)")

---

Tags

phplocalizationinternationalizationi18nlanguagel10ntranslationlocalepoppop php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/popphp-pop-i18n/health.svg)

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

###  Alternatives

[gettext/languages

gettext languages with plural rules

7530.3M11](/packages/gettext-languages)[aplus/language

Aplus Framework Language Library

2351.7M15](/packages/aplus-language)[tractorcow/silverstripe-fluent

Simple localisation for Silverstripe

92421.6k26](/packages/tractorcow-silverstripe-fluent)[delight-im/i18n

Internationalization and localization for PHP

625.2k3](/packages/delight-im-i18n)[jrmajor/fluent

Fluent localization system for PHP

2716.9k5](/packages/jrmajor-fluent)[inpsyde/multilingual-press

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

2414.0k1](/packages/inpsyde-multilingual-press)

PHPackages © 2026

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