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

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

basteyy/php-i18n
================

A simple I18N functionality for PHP

1.0.2(1y ago)1491MITPHPPHP ^8.1

Since Nov 6Pushed 1y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

basteyy PHP I18n
================

[](#basteyy-php-i18n)

As an old [CakePHP](https://cakephp.org/) user, I started with the `__()` function. I liked the approach for small projects and created this small package for my own projects.

You use the `__()` somewhere in your code. As long, you don't create translations, the argument (string) will be returned. If you create a translation, the translation will be returned.

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

[](#installation)

```
composer require basteyy/php-i18n
```

Usage
-----

[](#usage)

The languages files are in ini format. For supporting all variants of strings, the key is hashed using the xxh3 algorithm (which is the fastest algorithm for php now).

```
; Content of /var/www/lang/de_DE.ini

; Original: Add
2519a9e8bc4544e5 = "Hinzufügen"

; Original: Remove
d93080c2fe513df2 = "Entfernen"

; Original: Remove %s Items
4937f99272d45d21 = "%s Dinge entfernen"
```

```
// Content of /var/www/index.php

use basteyy\I18n\I18n;

I18n::addTranslationFolder(__DIR__ . '/lang/');
I18n::addTranslationFolder(__DIR__ . '/another_folder/');
I18n::setTranslationLanguage('de_DE');

echo __('Add');
// Result: Hinzufügen

echo __("Remove");
// Result: Entfernen

echo __('Remove %s Item\'s ', 3212);
// Result: 3212 Dinge entfernen

echo __('A new string');
// Result: A new string

echo __('A new string with placeholder %s', 'inside');
// Result: A new string with placeholder inside
```

#### Translate an app/website

[](#translate-an-appwebsite)

You can use the bash script to generate the translation file. Please be aware, that this is a simple solution. It's easy to break it down with using `=`.

To translate an website, you can use the shell command

```
php vendor/basteyy/php-i18n/src/bin/I18nBaker source_folder target_file options --no-comments
```

In case you have your files, which shpuld be translated, stored under `/var/www/src/templates/` and you want to store the translation file at `/var/www/src/translations/dk_DK.ini`, you need to perform this:

```
php vendor/basteyy/php-i18n/src/bin/I18nBaker /var/www/src/templates/ /var/www/src/translations/dk_DK.ini
```

#### Options

[](#options)

You can append the following options:

`--no-comments` will output a translation file, without any comments.

```
php vendor/basteyy/php-i18n/src/bin/I18nBaker /var/www/src/templates/ /var/www/src/translations/dk_DK.ini --no-comments
```

Todo
----

[](#todo)

- Write tests
- Add more options to the shell command
- Create a solid shell app (maybe with symfony/console)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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

Every ~98 days

Total

3

Last Release

720d ago

### Community

Maintainers

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

---

Top Contributors

[![basteyy](https://avatars.githubusercontent.com/u/2758879?v=4)](https://github.com/basteyy "basteyy (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/translation

Provides tools to internationalize your application

6.6k836.5M2.1k](/packages/symfony-translation)[nesbot/carbon

An API extension for DateTime that supports 281 different languages.

169661.4M4.8k](/packages/nesbot-carbon)[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.4M494](/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)

PHPackages © 2026

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