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

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

sagittariusx/beluga.translation
===============================

A PHP translation/localization library

0.1.1(9y ago)0411LGPLv3PHPPHP &gt;=7.0

Since Aug 23Pushed 9y agoCompare

[ Source](https://github.com/SagittariusX/Beluga.Translation)[ Packagist](https://packagist.org/packages/sagittariusx/beluga.translation)[ RSS](/packages/sagittariusx-belugatranslation/feed)WikiDiscussions master Synced today

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

Beluga.Translation
==================

[](#belugatranslation)

A PHP translation/localization library

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

[](#installation)

Install it via

```
composer require sagittariusx/beluga.translation

```

or inside the `composer.json`:

```
   "require": {
      "sagittariusx/beluga.translation": "^0.1.1"
   },
```

Usage
-----

[](#usage)

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

### First step, the Locale

[](#first-step-the-locale)

Create a new Locale instance

```
use \Beluga\Tranlation\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 it is 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();
}
```

### Inside you app or lib

[](#inside-you-app-or-lib)

For example if you have an class that requires Localization

```
use \Beluga\Translation\{Locale,Translator};
use \Beluga\Translation\Source\ArraySource;

class Foo
{

   /**
    * @type \Beluga\Translation\Translator
    */
   private $trans;

   public function __construct( Locale $locale = null )
   {

      $_locale = null;

      if ( ! \is_null( $locale ) )
      {
         $_locale = $locale
      }

      else if ( Locale::HasGlobalInstance() )
      {
         $_locale = Locale::GetGlobalInstance();
      }

      if ( ! \is_null( $_locale ) )
      {
         $source = ArraySource::LoadFromFolder( __DIR__ . '/i18n', $_locale, false );
         $this->trans = new Translator( $source )
      }

   }

   public function getTranslation( $mainLanguageText )
   {

      if ( ! ( $this->trans instanceof ITranlator ) )
      {
         return $mainLanguageText;
      }

      return $this->trans->translateByText( $mainLanguageText );

   }

}
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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 ~0 days

Total

2

Last Release

3597d ago

### Community

Maintainers

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

---

Top Contributors

[![UniKado](https://avatars.githubusercontent.com/u/6945587?v=4)](https://github.com/UniKado "UniKado (4 commits)")[![SagittariusX](https://avatars.githubusercontent.com/u/20841191?v=4)](https://github.com/SagittariusX "SagittariusX (1 commits)")

### Embed Badge

![Health badge](/badges/sagittariusx-belugatranslation/health.svg)

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

###  Alternatives

[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)
