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

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

mireiawen/translation
=====================

Sets up the text translation domain and other settings for gettext translations

0.2.1(6y ago)040MITPHPPHP &gt;=7.3.0

Since Sep 22Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Mireiawen/translation)[ Packagist](https://packagist.org/packages/mireiawen/translation)[ RSS](/packages/mireiawen-translation/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (3)Used By (0)

Translation
===========

[](#translation)

Helper class to set up the text translation domain and other settings for gettext translations

- Class name: `Translation`
- Namespace: `Mireiawen\Translation`

Requirements
------------

[](#requirements)

- Intl extension
- PHP 7

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

[](#installation)

You can clone or download the code from the [GitHub repository](https://github.com/Mireiawen/translation) or you can use composer: `composer require mireiawen/translation`

Methods
-------

[](#methods)

### \_\_construct

[](#__construct)

```
Translation::__construct(string $path, string $default_language, string $domain, string $codeset = 'UTF-8')

```

Set up the translation and try to detect the user settings

#### Arguments

[](#arguments)

- **string** `$path` - The filesystem path to the translations
- **string** `$default_language` - The default language to use, if none can be determined
- **string** `$domain` - The text domain to bind to
- **string** `$codeset` - The character set to use with the translation file

#### Exceptions thrown

[](#exceptions-thrown)

##### \\Exception

[](#exception)

- In case the extension is missing
- In case the translation folder does not exist
- In case the language cannot be determined

### GetLanguage

[](#getlanguage)

```
Translation::GetLanguage()

```

Get the user's currently selected language

#### Return value

[](#return-value)

- **string** - The current language code

### TranslateTo

[](#translateto)

```
Translation::TranslateTo(string $language, string $domain, string $codeset = 'UTF-8')

```

Set up the environment to load the correct translation file for the chosen language

#### Arguments

[](#arguments-1)

- **string** `$language` - The language to load
- **string** `$domain` - The text domain to bind to
- **string** `$codeset` - The character set to use with the translation file

#### Exceptions thrown

[](#exceptions-thrown-1)

##### \\Exception

[](#exception-1)

- In case the language is empty

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

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

Total

2

Last Release

2459d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b939943c063fd46acb5c8cd353ed8f69511ea19527d9196a09c382e828847bc?d=identicon)[Mireiawen](/maintainers/Mireiawen)

---

Top Contributors

[![Mireiawen](https://avatars.githubusercontent.com/u/11092031?v=4)](https://github.com/Mireiawen "Mireiawen (2 commits)")

### Embed Badge

![Health badge](/badges/mireiawen-translation/health.svg)

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

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