Download the PHP package nixphp/i18n without Composer
On this page you can find all versions of the php package nixphp/i18n. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package i18n
[!IMPORTANT] NixPHP is now NAF — "Not Another Framework".
This package continues as
naf/i18n: github.com/nafphp/i18n · documentation · what changed and how to moveThe old name collided with NixOS down to the shell, where the CLI binary was literally
nix. This repository is archived and receives no further releases;nixphp/i18nstays on Packagist so existing installations keep working.Note the plugin type. NAF discovers plugins by the Composer type
naf-plugin. A package still declaringnixphp-pluginis not loaded — silently, with no error.
nixphp/i18n
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
- Loads language files from
app/Resources/lang/ - Configure translation file path via config key
app:translationPath(uselanguageto set the language) - 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
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
If you don't configure a language, the default language is English (
en).
🔍 Translate
Assuming app/Resources/lang/en.json contains:
You’ll see:
Welcome to our site!
✨ With replacements
With this JSON entry:
Result:
Hello, John!
🌍 Switch language
Make sure app/Resources/lang/de.json exists.
Through query parameter
An event listener will set the language based on the query parameter within a cookie.
🔄 Fallback
If a key is missing, the key itself is returned:
This helps you spot missing translations during development.
📁 File structure
Each file should be a flat key-value map using UTF-8 encoded JSON.
✅ Requirements
nixphp/framework>= 0.1.0- PHP >= 8.1
📄 License
MIT License.