PHPackages                             clusteramaryllis/gettext - 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. clusteramaryllis/gettext

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

clusteramaryllis/gettext
========================

Adds localization support to laravel applications with PoEdit and Gettext

1.3.2(10y ago)46575GPL-2.0PHPPHP &gt;=5.5.9

Since Feb 5Pushed 10y ago1 watchersCompare

[ Source](https://github.com/clusteramaryllis/laravel-gettext)[ Packagist](https://packagist.org/packages/clusteramaryllis/gettext)[ RSS](/packages/clusteramaryllis-gettext/feed)WikiDiscussions 1.3 Synced 1mo ago

READMEChangelogDependencies (4)Versions (18)Used By (0)

laravel-gettext
===============

[](#laravel-gettext)

[![Build Status](https://camo.githubusercontent.com/f81ae4664b2a8df75008de34c55da6e63594ccae1456cbae591140d4f7a11381/68747470733a2f2f7472617669732d63692e6f72672f636c7573746572616d6172796c6c69732f6c61726176656c2d676574746578742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/clusteramaryllis/laravel-gettext)

### Installation

[](#installation)

Laravel 5.2 Installation

Add the composer repository to your *composer.json* file:

```
"require": {
    "clusteramaryllis/gettext": "1.3.x"
}
```

- For Laravel 5.1, checkout [1.2 branch](https://github.com/clusteramaryllis/laravel-gettext/tree/1.2)
- For Laravel 4.2, checkout [0.3 branch](https://github.com/clusteramaryllis/laravel-gettext/tree/0.3)

And run `composer update`. Once finished, register via service provider in `config/app.php` in the `providers` array:

```
'providers' => [

    // ...

    Clusteramaryllis\Gettext\GettextServiceProvider::class,

]
```

You can also provide static syntax via facade in the `aliases` array:

```
'aliases' => [

    // ...

    'Gettext' => Clusteramaryllis\Gettext\Facades\Gettext::class,

]
```

Publish the configuration file (optional) (will create on `config/gettext.php`) :

```
php artisan vendor:publish
```

### Command

[](#command)

**Available commands**

`gettext:create` =&gt; Generate new .po file

`gettext:update` =&gt; Update existing .po file

**Available options**

Check with `php artisan gettext:create --help` or `php artisan gettext:update --help`

**Example**

```
php artisan gettext:create --sources="app/Http/Controllers, resources/views" --destination="resources/locale" --locale="en_US"
```

This will generate .po files in `resources/locale/en_US/LC_MESSAGES/messages.po` &amp; will scan any string that utilize [php-gettext](http://php.net/manual/en/ref.gettext.php) function on `app/Http/Controllers` &amp; `resources/views`

Once done, you can easily translate your application using tools such as PoEdit.

### How To

[](#how-to)

**Simple usage**

1. Prepare `view` with strings wrapped with `Gettext` method or helper

```

{!! __('Welcome to main page') !!}
```

2. Add your language preferences via `config/gettext.php` on languages array

```
languages => [

    // ...,

    'sv' => [
        'locale' => 'sv_SE',
        'encoding' => 'utf-8',
        'plural_forms' => "nplurals=2; plural=(n != 1);",
    ]
]
```

3. Run `php artisan gettext:create`. This will generate .po file in

```
resources\locale\sv_SE\LC_MESSAGES\messages.po

```

&amp; ready to scan translated string in `app\Http\Controllers` &amp; `resources\views` (Default option).

4. Open the .po file with PoEdit or any similar editors. In PoEdit you need to click update to populate the table with the scanned strings. After that, you can start begin translating.
5. Simple routes test

```
Route::get('/', function() {

    Gettext::bindTextDomain('messages', base_path('resources/locale'));
    Gettext::textDomain('messages');

    Gettext::setLocale(LC_ALL, 'sv_SE.utf-8');

    return view('welcome');
});
```

**Available methods**

MethodsHelper shortcutGettext::setLocale\_setlocaleGettext::bindTextDomain\_bindtextdomainGettext::bindTextDomainCodeset\_bind\_text\_domain\_codesetGettext::textDomain\_textdomainGettext::getText\_\_Gettext::nGetText\_nGettext::dGetText\_dGettext::dNGetText\_dnGettext::dCGetText\_dcGettext::dCNGetText\_dcnGettext::pGetText\_pGettext::dPGetText\_dpGettext::dCPGetText\_dcpGettext::nPGetText\_npGettext::dNPGetText\_dnpGettext::dCNPGetText\_dcnpMore detailed method &amp; their parameters can be seen [here](https://github.com/clusteramaryllis/laravel-gettext/blob/master/src/Gettext.php).

### Acknowledgements

[](#acknowledgements)

This package is inspired by [laravel-gettext](https://github.com/xinax/laravel-gettext/) by Nicolás Daniel Palumbo for .po files creation &amp; utilize [php-gettext](https://launchpad.net/php-gettext/) package by Danilo Segan.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

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

Recently: every ~30 days

Total

17

Last Release

3724d ago

Major Versions

0.3.2 → 1.0.02015-02-05

0.3.3 → 1.0.12015-02-11

0.3.x-dev → 1.1.02015-06-17

PHP version history (2 changes)0.3.2PHP &gt;=5.4.0

1.1.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/92b86b625ae6bb5f2a80f16dddba3bdf5c7fa162d80c583eec9a904e53338e8f?d=identicon)[clusteramaryllis](/maintainers/clusteramaryllis)

---

Top Contributors

[![clusteramaryllis](https://avatars.githubusercontent.com/u/5319828?v=4)](https://github.com/clusteramaryllis "clusteramaryllis (109 commits)")

---

Tags

phplaravellocalizationtranslationgettextpoEditlaravel-gettext

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clusteramaryllis-gettext/health.svg)

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

###  Alternatives

[zerospam/laravel-gettext

Adds localization support to laravel applications in an easy way using Poedit and GNU gettext.

102207.4k](/packages/zerospam-laravel-gettext)[tio/laravel

Add this package to localize your Laravel application (PHP, JSON or GetText).

170318.5k](/packages/tio-laravel)

PHPackages © 2026

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