PHPackages                             eusonlito/laravel-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. eusonlito/laravel-gettext

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

eusonlito/laravel-gettext
=========================

Simple gettext loader and parser

v2.0.8(6y ago)98.8k4[1 issues](https://github.com/eusonlito/laravel-Gettext/issues)2MITPHPPHP &gt;=5.3

Since Apr 25Pushed 6y ago3 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (36)Used By (2)

Laravel 5.4 Gettext
===================

[](#laravel-54-gettext)

With this package you can load/parse/store gettext strings

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

[](#installation)

Begin by installing this package through Composer.

```
{
    "require": {
        "eusonlito/laravel-gettext": "2.0.*"
    }
}
```

### Laravel installation

[](#laravel-installation)

> Note: If you are using Laravel 5.5 or above, the next steps for providers and aliases are unnecessaries. laravel-Gettext supports Laravel new [Package Discovery](https://laravel.com/docs/master/packages#package-discovery).

```
// config/app.php

'providers' => [
    '...',
    'Eusonlito\LaravelGettext\GettextServiceProvider',
];

'aliases' => [
    '...',
    'Gettext'    => 'Eusonlito\LaravelGettext\Facade',
];
```

Now you have a `Gettext` facade available.

Publish the config file:

```
php artisan vendor:publish
```

### Usage

[](#usage)

```
__('Here your text');
__('Here your text with %s parameters', 1);
__('Here your text with parameters %s and %s', 1, 2);
```

Gettext Files
=============

[](#gettext-files)

By default, gettext .po and .mo files are stored in resources/gettext/xx\_XX/LC\_MESSAGES/messages.XX

xx\_XX is language code like `en_US`, `es_ES`, etc...

Using your own Gettext function/helper
======================================

[](#using-your-own-gettext-functionhelper)

If you want to create your alternative gettext function:

```
// config/app.php

'providers' => [
    '...',
    'Eusonlito\LaravelGettext\GettextServiceProvider',
    'App\Providers\GettextServiceProvider',
];
```

Create the file:

```
// app/Providers/GettextServiceProvider.php
