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

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

stantabcorp/i18n
================

Internationalization library for PHP

1.4.3(6y ago)43.6k↓13.3%proprietaryPHPCI failing

Since Aug 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/stantabcorp/i18n)[ Packagist](https://packagist.org/packages/stantabcorp/i18n)[ Docs](https://github.com/stantabcorp/i18n)[ RSS](/packages/stantabcorp-i18n/feed)WikiDiscussions master Synced today

READMEChangelog (10)DependenciesVersions (14)Used By (0)

i18n
====

[](#i18n)

Internationalization library for PHP This library allows you to translate your website with ini files, Auto Detecting the language and much more!

[![Latest Stable Version](https://camo.githubusercontent.com/f0ea9eaa5e11d962fa3a2c4b7da238d72ce8dfeedb07465d89309fa842accd34/68747470733a2f2f706f7365722e707567782e6f72672f7374616e746162636f72702f6931386e2f762f737461626c65)](https://packagist.org/packages/stantabcorp/i18n)[![Total Downloads](https://camo.githubusercontent.com/f54833b078b59ad4f8de7ce7a8cbf87f49441ad217e6ac59227eaa5e3e25098d/68747470733a2f2f706f7365722e707567782e6f72672f7374616e746162636f72702f6931386e2f646f776e6c6f616473)](https://packagist.org/packages/stantabcorp/i18n)

Documentation
-------------

[](#documentation)

### Information

[](#information)

i18n will create a folder named "i18n" please make sure it is readable

### Installation

[](#installation)

1. Via composer: `composer require stantabcorp/i18n`
2. Via manually download and install

### Initialization

[](#initialization)

In the i18n constructor your must-have **3** parameters:

1. The language you want to display your website **or** true to use AutoDetect
2. The default language
3. An array of available languages
4. An array of options

**Example:**Without AutoDetect:

```
$i18n = new i18n("en", "en", ["en", "fr"])

```

This will set the language to `en` (English), set the default language to `en` (English) and set that `en` (English) and `fr` (French) are available

With AutoDetect:

```
$i18n = new i18n(true, "en", ["en", "fr"])

```

This will set the language to AutoDetect, set the default language and set available language for AutoDetect

AutoDetect, use the Accept-Language HTTP Header to determine the best matching locale to use.

### Usage

[](#usage)

In order to get a translation you just need to:

```
$i18n->get("index_in_your_file");
```

If you want to use sections in your ini file use the following syntax:

```
$i18n->get("section_name[index_in_your_file]");
// OR
$i18n->get("section_name.index_in_your_file");
```

If you want to get the current language:

```
$i18n->getLang();
```

You want to change the language?

```
$i18n->setLang("language");
```

You don't want to use `sprintf`?! No problem:

```
$i18n->replace("string", [
    "string" => "strong"
]);
```

Want to change the translation folder on the fly?

```
$i18n->setFolder("path/to/the/new/folder");
```

Want to get the active folder?

```
$i18n->getFolder();
```

Want to set the available languages?

```
$i18n->setAvailableLanguages(array);
```

Want to get the available languages?

```
$i18n->getAvailableLanguage();
```

Now, let set and get the default language

```
$i18n->setDefaultLanguage("string");
$i18n->getDefaultLanguage();
```

### File syntax

[](#file-syntax)

**Sections are supported by i18n, see options to enable it**

*Example file:*

```
word1 = "Some word"
word2 = "Some other word"

[section_name]
word1 = "A word in a section"
word2 = "Another word in the same section"
```

### Options

[](#options)

The fourth parameter when initializing the i18n class is an array.
Accepted values are:

- `error`, a boolean to enable or disable error throwing
- `sections`, a boolean to enable or not sections in the ini files
- `path`, to set a path for the translations

### Twig Extension

[](#twig-extension)

i18n provide a simple Twig extension. To enable it, simply add a new extension to twig:

```
$i18nTwig = new i18nTwigExtension($i18n); // $i18n should be an instance of i18n\i18n
$twig->addExtension($i18nTwig);
```

In order to use it in a twig template, simply call (with the same syntax for section):

```
{{ i18n('index in your file') }}
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity70

Established project with proven stability

 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 ~74 days

Recently: every ~83 days

Total

13

Last Release

2358d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5327e23311a2e1157e38b676f316ba80ec836408b23a342dec4c0851ea91c19a?d=identicon)[stantabcorp](/maintainers/stantabcorp)

---

Top Contributors

[![thibaultjunin](https://avatars.githubusercontent.com/u/12583049?v=4)](https://github.com/thibaultjunin "thibaultjunin (18 commits)")

---

Tags

autodetecti18ninternationalization-libraryintllanguagephptranslatetranslationtranslationstranslator

### Embed Badge

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

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

###  Alternatives

[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1927.0k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

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