PHPackages                             niirrty/niirrty.translation - 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. niirrty/niirrty.translation

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

niirrty/niirrty.translation
===========================

A PHP translation library.

0.6.1(2y ago)1211↓90.9%[1 issues](https://github.com/Niirrty/Niirrty.Translation/issues)2MITPHPPHP &gt;=8.1CI failing

Since Nov 1Pushed 2y agoCompare

[ Source](https://github.com/Niirrty/Niirrty.Translation)[ Packagist](https://packagist.org/packages/niirrty/niirrty.translation)[ RSS](/packages/niirrty-niirrtytranslation/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (5)Versions (13)Used By (2)

Niirrty.Translation
===================

[](#niirrtytranslation)

A small PHP file based translation library.

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

[](#installation)

inside the `composer.json`:

```
{
   "require": {
      "php": ">=8.1",
      "niirrty/niirrty.translation": "~0.6"
   }
}
```

How to use
----------

[](#how-to-use)

```
include __DIR__ . '/vendor/autoload.php';

use \Niirrty\Locale\Locale;
use \Niirrty\Translation\Sources\PHPFileSource;
use \Niirrty\Translation\Translator;

try
{
    // Init the locale
    $locale = Locale::Create(
        // The fallback locale if no other was found
        new Locale( 'de', 'de', 'UTF-8' ),
        // Check also the URL path for an locale or language part?
        true,
        // This are the names of the parameters, accepted from $_POST, $_GET and $_SESSION
        [ 'lc', 'locale', 'language', 'lang', 'lng' ]
    );

    // Init the translator instance with defined locale
    $translator = new Translator( $locale );

    // Define the templates source directory. There is also a JSONFileSource and a XMLFileSource
    $translatorSource = new PHPFileSource( __DIR__ . '/translations', $locale );
    // ...and add the source to template engine
    $translator->addSource( $translatorSource );

    // If you want access the Translator instance globally
    $translator->setAsGlobalInstance();

    // Example output
    echo Translator::GetInstance()->read( 'Hello1', 'MyApp', 'Hello people!' ), "\n",
         $translator->read( 'NiceTM', 'MyApp', 'NiceToMeetYouM!' );

}
catch ( \Throwable $ex )
{
    // TODO: Do some error handling
}
```

Translation sources
-------------------

[](#translation-sources)

A translator must have 1 or more translation sources. Each source defines a directory, that must contain the translation source files, for all supported languages.

### Translation files

[](#translation-files)

- The **file name** (without extension) must be the locale name. (eg. `de` or `de_AT` )
- The **file extension** must be supported by the used `ISource` implementation. Currently known is `.php` (PHPFileSource) `.json` (JSONFileSource) and `.xml` (XMLFileSource)

### Example directory structure

[](#example-directory-structure)

```
+ translations
   - de.php
   - de_DE.php
   - en.php
   - fr_FR.php

```

### PHP file source

[](#php-file-source)

Format is:

```

   Ein anderer Beispieltext

      Ein ganz anderer Beispieltext

      Text 4
      Hallo Welt

         Montag
         Dienstag
         Mittwoch
         Donnerstag
         Freitag
         Samstag
         Sonntag

      weekdaysDict

         Montag
         Dienstag
         Mittwoch
         Donnerstag
         Freitag
         Samstag
         Sonntag

```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity69

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

Recently: every ~236 days

Total

11

Last Release

862d ago

PHP version history (3 changes)0.1.0PHP &gt;=7.1

0.4.0PHP &gt;=8.0

0.6.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/56201fee0dd151f8d0ce7dfe228cc74aa1bae7949664bc8644cdb5620e329b88?d=identicon)[Niirrty](/maintainers/Niirrty)

---

Top Contributors

[![Niirrty](https://avatars.githubusercontent.com/u/33220884?v=4)](https://github.com/Niirrty "Niirrty (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/niirrty-niirrtytranslation/health.svg)

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[symfony/http-kernel

Provides a structured process for converting a Request into a Response

8.1k853.6M8.3k](/packages/symfony-http-kernel)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k365.0M3.1k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[jms/translation-bundle

Puts the Symfony Translation Component on steroids

42411.0M74](/packages/jms-translation-bundle)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)

PHPackages © 2026

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