clusteramaryllis/gettext
Larablocks Analysis
clusteramaryllis/gettext works with Laravel 5 (latest release 1.3.2, Mar 1, 2016), which reached end of life: no more fixes, even for security.
Laravel 4 in earlier releases.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 5, past end of life
- No release in the last 12 months (last: Mar 1, 2016)
- 0 downloads a month (needs 10,000)
- 4 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Mar 1, 2016.
- No releases in the last 12 months.
- First released: Feb 5, 2015.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 3, 2026.
| Install | |
|---|---|
composer require clusteramaryllis/gettext |
|
| Latest Version: | 1.3.2 |
| PHP: | >=5.5.9 |
| Laravel: | 5 |
| Older releases: | 4 |
| License: | GPL-2.0 |
| Last Updated: | Mar 1, 2016 |
| Links: | GitHub · Packagist |
laravel-gettext
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
- For Laravel 4.2, checkout 0.3 branch
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
Available commands
gettext:create => Generate new .po file
gettext:update => 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 & will scan any string that utilize php-gettext function on app/Http/Controllers & resources/views
Once done, you can easily translate your application using tools such as PoEdit.
How To
Simple usage
- Prepare
viewwith strings wrapped withGettextmethod or helper
<!-- resources\views\welcome.blade.php -->
{!! __('Welcome to main page') !!}
- Add your language preferences via
config/gettext.phpon languages array
languages => [
// ...,
'sv' => [
'locale' => 'sv_SE',
'encoding' => 'utf-8',
'plural_forms' => "nplurals=2; plural=(n != 1);",
]
]
- Run
php artisan gettext:create. This will generate .po file in
resources\locale\sv_SE\LC_MESSAGES\messages.po
& ready to scan translated string in app\Http\Controllers & resources\views (Default option).
-
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.
-
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
| Methods | Helper shortcut |
|---|---|
| Gettext::setLocale | _setlocale |
| Gettext::bindTextDomain | _bindtextdomain |
| Gettext::bindTextDomainCodeset | _bind_text_domain_codeset |
| Gettext::textDomain | _textdomain |
| Gettext::getText | __ |
| Gettext::nGetText | _n |
| Gettext::dGetText | _d |
| Gettext::dNGetText | _dn |
| Gettext::dCGetText | _dc |
| Gettext::dCNGetText | _dcn |
| Gettext::pGetText | _p |
| Gettext::dPGetText | _dp |
| Gettext::dCPGetText | _dcp |
| Gettext::nPGetText | _np |
| Gettext::dNPGetText | _dnp |
| Gettext::dCNPGetText | _dcnp |
More detailed method & their parameters can be seen here.
Acknowledgements
This package is inspired by laravel-gettext by Nicolás Daniel Palumbo for .po files creation & utilize php-gettext package by Danilo Segan.
Alternatives to clusteramaryllis/gettext
Add this package to localize your Laravel application (PHP, JSON or GetText).
Detects the user’s preferred language and redirects to the matching localized UR...
A convenient way to set up, manage and use localized routes in a Laravel app.
A convenient way to set up, manage and use localized routes in a Laravel app.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.3.2 | >=5.5.9 | 5.2.* | GPL-2.0 | |
| 1.3.1 | >=5.5.9 | 5.2.* | GPL-2.0 | |
| 1.3.0 | >=5.5.9 | 5.2.* | GPL-2.0 | |
| 1.2.0 | >=5.5.9 | 5.1.* | GPL-2.0 | |
| 1.1.1 | >=5.5.9 | 5.1.* | GPL-2.0 | |
| 1.1.0 | >=5.5.9 | 5.1.* | GPL-2.0 | |
| 1.0.3 | >=5.4.0 | 5.0.* | GPL-2.0 | |
| 1.0.2 | >=5.4.0 | 5.0.* | GPL-2.0 | |
| 1.0.1 | >=5.4.0 | 5.0.* | GPL-2.0 | |
| 1.0.0 | >=5.4.0 | 5.0.* | GPL-2.0 | |
| 0.3.3 | >=5.4.0 | 4.2.* | GPL-2.0 | |
| 0.3.2 | >=5.4.0 | 4.2.* | GPL-2.0 |