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

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

niirrty/niirrty.locale
======================

A PHP locale library.

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

Since Oct 31Pushed 2y agoCompare

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

READMEChangelog (10)Dependencies (1)Versions (11)Used By (1)

Niirrty.Locale
==============

[](#niirrtylocale)

The Locale class and some helpers

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

[](#installation)

inside the `composer.json`:

```
{
   "require": {
      "php": ">=8.1",
      "niirrty/niirrty.locale": "^0.6"
   }
}
```

Usage
-----

[](#usage)

If you want to use this package inside you're application include the depending composer autoload.php

### The Locale

[](#the-locale)

Create a new Locale instance

```
use \Niirrty\Locale\Locale;

Locale::Create(
   // The fallback locale if no other was found
   new Locale( 'de', 'AT', '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
   [ 'locale', 'language', 'lang' ]
)
   ->registerAsGlobalInstance();
```

This creates the new Locale by checking the following places to get the required information

- First The current URL part is checked, if it contains an valid locale string, it is used (you can disable it by setting the 2nd Create parameter to FALSE.
- Next it checks if one of the defined request parameters (3rd parameter) is defined by $\_POST, $\_GET or $\_SESSION
- After that, its checked if the browser sends some information about the preferred locale/language.
- Finally it is checked if the system gives usable locale information.

If all this methods fail, the declared fall back locale is returned. You can also call it main locale.

Last but not least the created locale is registered as global available Locale instance. It can be accessed from other places by:

```
if ( Locale::HasGlobalInstance() )
{
   $locale = Locale::GetGlobalInstance();
}
else
{
   // Create the locale
   //$locale = Locale::Create( … )->registerAsGlobalInstance();
}
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity68

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

Recently: every ~230 days

Total

10

Last Release

861d ago

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

0.4.0PHP &gt;=8.0

0.5.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 (9 commits)")

### Embed Badge

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

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

###  Alternatives

[php-translation/translator

Translator services

25224.8k5](/packages/php-translation-translator)[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.

1926.6k1](/packages/smmoosavi-php-gettext)[laradevs/spanish

labels translated to spanish

166.7k](/packages/laradevs-spanish)

PHPackages © 2026

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