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

ActiveNixphp-plugin[Localization &amp; i18n](/categories/localization)

nixphp/i18n
===========

NixPHP Internationalization Plugin

v0.1.3(4mo ago)0102MITPHPPHP &gt;=8.3CI passing

Since Nov 30Pushed 4mo agoCompare

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

READMEChangelog (4)Dependencies (3)Versions (9)Used By (0)

[![Logo](https://camo.githubusercontent.com/075b2860e9651b98b8c190a8296595c54cff6900890d9e494f31131145e98a6f/68747470733a2f2f6e69787068702e6769746875622e696f2f646f63732f6173736574732f6e69787068702d6c6f676f2d736d616c6c2d7371756172652e706e67)](https://camo.githubusercontent.com/075b2860e9651b98b8c190a8296595c54cff6900890d9e494f31131145e98a6f/68747470733a2f2f6e69787068702e6769746875622e696f2f646f63732f6173736574732f6e69787068702d6c6f676f2d736d616c6c2d7371756172652e706e67)

[![NixPHP I18n Plugin](https://github.com/nixphp/i18n/actions/workflows/php.yml/badge.svg)](https://github.com/nixphp/i18n/actions/workflows/php.yml)

[← Back to NixPHP](https://github.com/nixphp/framework)

---

nixphp/i18n
===========

[](#nixphpi18n)

> **Simple JSON-based translations for your NixPHP application.**

This plugin provides a lightweight translation system for multilingual apps. It reads language files from disk, supports variable replacements, and falls back gracefully — all with minimal overhead.

> 🧩 Part of the official NixPHP plugin collection. Install it if you want clean, flexible localization without external libraries.

---

📦 Features
----------

[](#-features)

- ✅ Loads language files from `app/Resources/lang/`
- ✅ Set language via config with key app:translationPath
- ✅ Supports `t('key')` with a fallback mechanism
- ✅ Replaces variables via `:name`, `:count`, etc.
- ✅ Language codes follow ISO 639-1 (e.g. `en`, `de`, `fr`)
- ✅ JSON-based – easy to edit, export, and manage

---

📥 Installation
--------------

[](#-installation)

```
composer require nixphp/i18n
```

The plugin auto-registers and makes a `t()` as well as a `translator()` helper available globally. The `t()` function accepts a key and an optional array of replacements, while `translator()` is a shortcut to access the translator directly.

---

🚀 Usage
-------

[](#-usage)

> If you don't configure a language, the default language is English (`en`).

### 🔍 Translate

[](#-translate)

```
echo t('welcome');
```

Assuming `app/Resources/lang/en.json` contains:

```
{
  "welcome": "Welcome to our site!"
}
```

You’ll see: `Welcome to our site!`

---

### ✨ With replacements

[](#-with-replacements)

```
echo t('greeting', ['name' => 'John']);
```

With this JSON entry:

```
{
  "greeting": "Hello, :name!"
}
```

Result: `Hello, John!`

---

### 🌍 Switch language

[](#-switch-language)

```
t()->setLanguage(Language::DE);
```

Make sure `app/Resources/lang/de.json` exists.

#### Through query parameter

[](#through-query-parameter)

```
/index.php?lang=de
```

> An event listener will set the language based on the query parameter within a cookie.

---

### 🔄 Fallback

[](#-fallback)

If a key is missing, the key itself is returned:

```
translator()->get('unknown_key');
// → "unknown_key"
```

This helps you spot missing translations during development.

---

📁 File structure
----------------

[](#-file-structure)

```
app/
└── Resources/
    └── lang/
        ├── en.json
        ├── de.json
        └── fr.json

```

Each file should be a flat key-value map using UTF-8 encoded JSON.

---

✅ Requirements
--------------

[](#-requirements)

- `nixphp/framework` &gt;= 0.1.0
- PHP &gt;= 8.1

---

📄 License
---------

[](#-license)

MIT License.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance78

Regular maintenance activity

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Total

4

Last Release

122d ago

### Community

Maintainers

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

---

Top Contributors

[![FloKnapp](https://avatars.githubusercontent.com/u/3774820?v=4)](https://github.com/FloKnapp "FloKnapp (25 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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.4M495](/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)[inpsyde/multilingual-press

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

2414.0k1](/packages/inpsyde-multilingual-press)[statikbe/laravel-chained-translator

The Laravel Chained Translator can combine several translators that can override each others translations.

36149.4k6](/packages/statikbe-laravel-chained-translator)

PHPackages © 2026

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