PHPackages                             potsky/laravel-localization-helpers - 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. potsky/laravel-localization-helpers

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

potsky/laravel-localization-helpers
===================================

An artisan command package for easy translation management

v2.6.6(8y ago)189105.7k↓35.3%36[14 issues](https://github.com/potsky/laravel-localization-helpers/issues)[4 PRs](https://github.com/potsky/laravel-localization-helpers/pulls)GPL-3.0+PHP

Since Jun 10Pushed 7y ago11 watchersCompare

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

READMEChangelog (8)Dependencies (6)Versions (52)Used By (0)

Laravel Localization Helpers
============================

[](#laravel-localization-helpers)

[![Latest Stable Version](https://camo.githubusercontent.com/0bd64aa953741695b7ddee4063e0dc937f50b411d29d3525067a4f88c7fce6ae/68747470733a2f2f706f7365722e707567782e6f72672f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732f762f737461626c652e737667)](https://packagist.org/packages/potsky/laravel-localization-helpers)[![Latest Unstable Version](https://camo.githubusercontent.com/ae92e4c1c0891f07884d29c2732672eb8f68423331137d43a823746b11493b2b/68747470733a2f2f706f7365722e707567782e6f72672f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732f762f756e737461626c652e737667)](https://packagist.org/packages/potsky/laravel-localization-helpers)[![Build Status](https://camo.githubusercontent.com/f2fb066f4ff197a2c8a01d156a7270fa45a1451be8b3b0fe5f2640883e6a3831/68747470733a2f2f7472617669732d63692e6f72672f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732e737667)](https://travis-ci.org/potsky/laravel-localization-helpers)[![Coverage Status](https://camo.githubusercontent.com/41e97c34d91ec16e28e465cfe1777a1f290aed712b3d85ace3e5a267cd14a242/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732f62616467652e7376673f736572766963653d676974687562)](https://coveralls.io/github/potsky/laravel-localization-helpers)[![Total Downloads](https://camo.githubusercontent.com/adaf10e2af9e25968c83ccb4508e723188bb93f96b144cd19b083d775ca1bf0d/68747470733a2f2f706f7365722e707567782e6f72672f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732f646f776e6c6f6164732e737667)](https://packagist.org/packages/potsky/laravel-localization-helpers)[![Stories in Ready](https://camo.githubusercontent.com/82cd9c5cb908271eb0d37c26e3fc3077baee19647fd5d664e812238c5eece9c0/68747470733a2f2f62616467652e776166666c652e696f2f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732e706e673f6c6162656c3d7265616479267469746c653d5265616479)](https://waffle.io/potsky/laravel-localization-helpers)

This branch is the current dev branch
-------------------------------------

[](#this-branch-is-the-current-dev-branch)

LLH is a set of artisan commands to manage translations in your Laravel project. Key features :

- parse your code and generate lang files
- translate your sentences automatically, thanks to Microsoft Translator API
- configure output according to your code style

Table of contents
-----------------

[](#table-of-contents)

1. [Installation](#1-installation)
2. [Configuration](#2-configuration)
3. [Usage](#3-usage)
4. [Support](#4-support)
5. [Upgrade Notices](#5-upgrade-notices)
6. [Change Log](#6-change-log)
7. [Contribute](#7-contribute)

1. Installation
---------------

[](#1-installation)

- Choose your version according to the version compatibility matrix:

LaravelLumenPackage4.2.x2.0.x (EOL last version is 2.0.4)5.0.x2.1.x5.1.x5.1.x2.2.x5.2.x5.2.x2.3.x5.3.x5.3.x2.4.x5.4.x5.4.x2.5.x5.5.x5.5.x2.6.x- Add the following line in the `require-dev` array of the `composer.json` file and replace the version if needed according to your Laravel version:

    ```
    "potsky/laravel-localization-helpers" : "2.6.*"
    ```
- Update your installation : `composer update`
- For Laravel, add the following lines in the `AppServiceProvider` array of the `config/app.php` configuration file :

    ```
    Potsky\LaravelLocalizationHelpers\LaravelLocalizationHelpersServiceProvider::class,
    ```

    On Laravel 5.5, if you don't use the package in production, disable auto-loading and register it only on `local` or `dev`:

    - Add the following lines in the `register` method of the `AppServiceProvider` :

        ```
         public function register()
         {
         	if ($this->app->environment() === 'dev') { // or local or whatever
         		$this->app->register(\Potsky\LaravelLocalizationHelpers\LaravelLocalizationHelpersServiceProvider::class);
         	}
         }
        ```
    - Disable to auto-register provider by adding these lines in the `composer.json` file:

        ```
         "extra" : {
         	"laravel" : {
         		"dont-discover" : [
         			"potsky/laravel-localization-helpers"
         		]
         	}
         }
        ```
- For Lumen, add the following lines in the `bootstrap/app.php` file :

    ```
     $app->register( Potsky\LaravelLocalizationHelpers\LaravelLocalizationHelpersServiceProvider::class );
     $app->configure('laravel-localization-helpers');
    ```
- Now execute `php artisan list` and you should view the new *localization* commands:

    ```
    ...
    localization
    localization:clear          Remove lang backup files
    localization:find           Display all files where the argument is used as a lemma
    localization:missing        Parse all translations in app directory and build all lang files
    ...

    ```

In Laravel, you can add the facade in the Aliases if you need to manage translations in your code :

```
'LocalizationHelpers' => Potsky\LaravelLocalizationHelpers\Facade\LocalizationHelpers::class
```

2. Configuration
----------------

[](#2-configuration)

To configure your fresh installed package, please create a configuration file by executing :

```
php artisan vendor:publish
```

Then you can modify the configuration in file :

```
config/laravel-localization-helpers.php
```

Add new folders to search for, add your own lang methods or functions, ...

> For Lumen, copy manually the [configuration file](https://github.com/potsky/laravel-localization-helpers/blob/master/src/config/config-laravel5.php) as `config/laravel-localization-helpers.php`.

### Backup files

[](#backup-files)

You should not include backup lang files in GIT or other versioning systems.

In your `laravel` folder, add this in `.gitignore` file :

```
# Do not include backup lang files
resources/lang/*/[a-zA-Z]*20[0-9][0-9][0-1][0-9][0-3][0-9]_[0-2][0-9][0-5][0-9][0-5][0-9].php
```

3. Usage
--------

[](#3-usage)

### 3.1 Command `localization:missing`

[](#31-command-localizationmissing)

This command parses all your code and generates translations according to lang files in all `lang/XXX/` directories.

Use `php artisan help localization:missing` for more informations about options.

#### *Examples*

[](#examples)

##### Generate all lang files

[](#generate-all-lang-files)

```
php artisan localization:missing
```

##### Generate all lang files without prompt

[](#generate-all-lang-files-without-prompt)

```
php artisan localization:missing -n
```

##### Generate all lang files without backuping old files

[](#generate-all-lang-files-without-backuping-old-files)

```
php artisan localization:missing -b
```

##### Generate all lang files with automatic translations

[](#generate-all-lang-files-with-automatic-translations)

```
php artisan localization:missing -t
```

> You need to set your Microsoft Bing Translator credentials More informations here :

##### Generate all lang files without keeping obsolete lemmas

[](#generate-all-lang-files-without-keeping-obsolete-lemmas)

```
php artisan localization:missing -o
```

##### Generate all lang files without any comment for new found lemmas

[](#generate-all-lang-files-without-any-comment-for-new-found-lemmas)

```
php artisan localization:missing -c
```

##### Generate all lang files without header comment

[](#generate-all-lang-files-without-header-comment)

```
php artisan localization:missing -d
```

##### Generate all lang files and set new lemma values

[](#generate-all-lang-files-and-set-new-lemma-values)

3 commands below produce the same output:

```
php artisan localization:missing
php artisan localization:missing -l
php artisan localization:missing -l "TODO: %LEMMA"
```

You can customize the default generated values for unknown lemmas.

The following command let new values empty:

```
php artisan localization:missing -l ""
```

The following command prefixes all lemma values with "Please translate this : "

```
php artisan localization:missing -l "Please translate this : %LEMMA"
```

The following command set all lemma values to null to provide fallback translations to all missing values.

```
php artisan localization:missing -l null
```

The following command set all lemma values to "Please translate this !"

```
php artisan localization:missing -l 'Please translate this !'
```

##### Silent option for shell integration

[](#silent-option-for-shell-integration)

```
#!/bin/bash

php artisan localization:missing -s
if [ $? -eq 0 ]; then
echo "Nothing to do dude, GO for release"
else
echo "I will not release in production, lang files are not clean"
fi
```

##### Simulate all operations (do not write anything) with a dry run

[](#simulate-all-operations-do-not-write-anything-with-a-dry-run)

```
php artisan localization:missing -r
```

##### Open all must-edit files at the end of the process

[](#open-all-must-edit-files-at-the-end-of-the-process)

```
php artisan localization:missing -e
```

You can edit the editor path in your configuration file. By default, editor is *Sublime Text* on *Mac OS X* :

```
'editor_command_line' => '/Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl'
```

For *PHPStorm* on *Mac OS X*:

```
'editor_command_line' => '/usr/local/bin/phpstorm'
```

### 3.2 Command `localization:find`

[](#32-command-localizationfind)

This command will search in all your code for the argument as a lemma.

Use `php artisan help localization:find` for more informations about options.

#### *Examples*

[](#examples-1)

##### Find regular lemma

[](#find-regular-lemma)

```
php artisan localization:find Search
```

##### Find regular lemma with verbose

[](#find-regular-lemma-with-verbose)

```
php artisan localization:find -v Search
```

##### Find regular lemma with short path displayed

[](#find-regular-lemma-with-short-path-displayed)

```
php artisan localization:find -s "Search me"
```

##### Find lemma with a regular expression

[](#find-lemma-with-a-regular-expression)

```
php artisan localization:find -s -r "@Search.*@"
php artisan localization:find -s -r "/.*me$/"
```

> PCRE functions are used

### 3.3 Command `localization:clear`

[](#33-command-localizationclear)

This command will remove all backup lang files.

Use `php artisan help localization:clear` for more informations about options.

#### *Examples*

[](#examples-2)

##### Remove all backups

[](#remove-all-backups)

```
php artisan localization:clear
```

##### Remove backups older than 7 days

[](#remove-backups-older-than-7-days)

```
php artisan localization:clear -d 7
```

4. Support
----------

[](#4-support)

Use the [github issue tool](https://github.com/potsky/laravel-localization-helpers/issues) to open an issue or ask for something.

5. Upgrade notices
------------------

[](#5-upgrade-notices)

### From `v2.x.5` to `v2.x.6`

[](#from-v2x5-to-v2x6)

- PHPCSFixer has changed. Previous fixers are not supported anymore. Take a look at the [configuration file](https://github.com/potsky/laravel-localization-helpers/tree/master/src/config) in the package to check new rules.

### From `v2.x.4` to `v2.x.5`

[](#from-v2x4-to-v2x5)

- Parameter `dot_notation_split_regex` has been added in the [configuration file](https://github.com/potsky/laravel-localization-helpers/tree/master/src/config). Add it in your configuration file.

### From `v2.x.1` to `v2.x.2`

[](#from-v2x1-to-v2x2)

- Parameter `obsolete_array_key` has been added in the [configuration file](https://github.com/potsky/laravel-localization-helpers/tree/master/src/config). Add it in your configuration file.

### From `v1.x.x` to `v2.x.x`

[](#from-v1xx-to-v2xx)

- First you need to update your composer file to set the correct version
- Take a look at the [configuration file](https://github.com/potsky/laravel-localization-helpers/tree/master/src/config) in the package to add new parameters you don't have in your current package configuration file.

6. Change Log
-------------

[](#6-change-log)

### v2.x.6

[](#v2x6)

- change: support Laravel 5.5
- change: update PHPCSFixer, rules have changed!
- change: translation package has been updated

### v2.x.5

[](#v2x5)

- new: `dot_notation_split_regex` has been added to automatically handle dots in lemma ([\#59](https://github.com/potsky/laravel-localization-helpers/issues/59))
- fix: ignore vendors lang folders ([\#59](https://github.com/potsky/laravel-localization-helpers/issues/59))
- new: you can now ignore specific lang files and not only lang families ([\#44](https://github.com/potsky/laravel-localization-helpers/issues/44))
- fix: in dry run mode, lang files were still created ([\#54](https://github.com/potsky/laravel-localization-helpers/issues/54))
- change: try to handle dynamic lemma errors ([\#53](https://github.com/potsky/laravel-localization-helpers/issues/53))
- change: change composer requirements to minimize lumen requirements ([\#49](https://github.com/potsky/laravel-localization-helpers/issues/49))
- change: handle indirect translation calls ([\#47](https://github.com/potsky/laravel-localization-helpers/issues/47))

### v2.x.4

[](#v2x4)

- new: Support of Laravel 5.3 from the `2.4.4` branch ([\#41](https://github.com/potsky/laravel-localization-helpers/issues/41))
- new: Track multi-line function calls ([\#33](https://github.com/potsky/laravel-localization-helpers/issues/33))
- new: Support translation's fallback by providing null in new value ([\#38](https://github.com/potsky/laravel-localization-helpers/issues/38))
- change: Use package `friendsofphp/php-cs-fixer` instead of `fabpot/php-cs-fixer` ([\#28](https://github.com/potsky/laravel-localization-helpers/issues/28))

### v2.x.3

[](#v2x3)

- new: adding possibility to disable check for obsolete lemmas ([\#27](https://github.com/potsky/laravel-localization-helpers/pull/27))
- fix: Short-Option for "output-flat" and "php-file-extension" changed because the two-letter-code doesn't work ([\#27](https://github.com/potsky/laravel-localization-helpers/pull/27))

### v2.x.2

[](#v2x2)

- show obsolete lemma when it is in array ([\#21](https://github.com/potsky/laravel-localization-helpers/issues/21))
- fix a bug when using obsolete option ([\#22](https://github.com/potsky/laravel-localization-helpers/issues/22))

### v2.x.1

[](#v2x1)

- fix a bug when using backup files and when a dot is in your laravel installation path ([\#20](https://github.com/potsky/laravel-localization-helpers/issues/20))

### v2.x.0

[](#v2x0)

- new command `localization:clear` to remove backups
- new option to specify output formatting ([\#17](https://github.com/potsky/laravel-localization-helpers/issues/17))
- new option to specify flat arrays style output ([\#18](https://github.com/potsky/laravel-localization-helpers/issues/18))
- new option to let the command translate sentences for you with Bing Translator
- new translations are now:
    - marked with the `TODO:` prefix by default (*if you ran two times the missing artisan command without translating lemma next to the first run, your missing translation were lost in the lang file. Now by default, just search for TODO in your lang file!*)
    - translated of course if option `t` is used
    - shorten to their minimal value ( `trans( 'message.child.this is a text' )` will now generate `['child'] => 'TODO: this is a text',` and no more `['child'] => 'TODO: child.this is a text',`)

Internally :

- totally refactored
- unit tests
- test coverage
- facade to let you use localization helpers in your code (translations, find missing translations, etc...)

### v1.3.3

[](#v133)

- End of life. Version 1.x is no more supported and no longer works. Please use the correct version according to your laravel version.

### v1.3.2

[](#v132)

- fix incompatibility with Laravel 5.2 ([\#16](https://github.com/potsky/laravel-localization-helpers/issues/16))

### v1.3.1

[](#v131)

- add resource folder for Laravel 5

### v1.3

[](#v13)

- add full support for Laravel 5

### v1.2.2

[](#v122)

- add support for @lang and @choice in Blade templates (by Jesper Ekstrand)

### v1.2.1

[](#v121)

- add `lang_folder_path` parameter in configuration file to configure the custom location of your lang files
- check lang files in `app/lang` by default for Laravel 4.x
- check lang files in `app/resources/lang` by default for Laravel 5

### v1.2

[](#v12)

- support for Laravel 5 (4.3)
- add `ignore_lang_files` parameter in configuration file to ignore lang files (useful for `validation` file for example)

7. Contribute
-------------

[](#7-contribute)

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Tests are in `tests`. To run the tests: `vendor/bin/phpunit`.

Coverage cannot decrease next a merge. To track file coverage, run `vendor/bin/phpunit --coverage-html coverage` and open `coverage/index.html` to check uncovered lines of code.

Dev badges : [![Dev Status](https://camo.githubusercontent.com/aa51ee4111319bc4877968202c5ecf568ddda451cf6ceefe3c26f33d2d533a22/68747470733a2f2f7472617669732d63692e6f72672f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732e7376673f6272616e63683d646576)](https://travis-ci.org/potsky/laravel-localization-helpers)[![Dev Coverage Status](https://camo.githubusercontent.com/1ce5b1ce016e429517b0bab8df71ac8cac2eb1c3b2a112d85f03d61facea3098/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f706f74736b792f6c61726176656c2d6c6f63616c697a6174696f6e2d68656c706572732f62616467652e7376673f6272616e63683d64657626736572766963653d676974687562)](https://coveralls.io/github/potsky/laravel-localization-helpers?branch=dev)

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 90.8% 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 ~34 days

Recently: every ~154 days

Total

49

Last Release

2730d ago

Major Versions

v2.4.5 → 5.3.x-dev2017-03-17

v2.3.5 → 5.2.x-dev2017-03-17

v2.2.5 → 5.1.x-dev2017-03-17

v2.1.5 → 5.0.x-dev2017-03-17

v2.6.6 → 5.6.x-dev2017-09-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/769401da6eb09b7a0e45be648517fc7042bcb33971caa36c0ccad3e2e2ea6b2b?d=identicon)[potsky](/maintainers/potsky)

---

Top Contributors

[![potsky](https://avatars.githubusercontent.com/u/408237?v=4)](https://github.com/potsky "potsky (157 commits)")[![limenet](https://avatars.githubusercontent.com/u/474329?v=4)](https://github.com/limenet "limenet (5 commits)")[![Liingon](https://avatars.githubusercontent.com/u/5780473?v=4)](https://github.com/Liingon "Liingon (4 commits)")[![adriandmitroca](https://avatars.githubusercontent.com/u/3842935?v=4)](https://github.com/adriandmitroca "adriandmitroca (2 commits)")[![shulard](https://avatars.githubusercontent.com/u/482993?v=4)](https://github.com/shulard "shulard (1 commits)")[![waffle-iron](https://avatars.githubusercontent.com/u/6912981?v=4)](https://github.com/waffle-iron "waffle-iron (1 commits)")[![daverdalas](https://avatars.githubusercontent.com/u/5399813?v=4)](https://github.com/daverdalas "daverdalas (1 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (1 commits)")[![RockKeeper](https://avatars.githubusercontent.com/u/8629442?v=4)](https://github.com/RockKeeper "RockKeeper (1 commits)")

---

Tags

bing-translatorlaravellaravel-packagelaravel-translation-managermanage-translationsphptranslation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/potsky-laravel-localization-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/potsky-laravel-localization-helpers/health.svg)](https://phpackages.com/packages/potsky-laravel-localization-helpers)
```

###  Alternatives

[barryvdh/laravel-translation-manager

Manage Laravel Translations

1.7k3.6M17](/packages/barryvdh-laravel-translation-manager)[vluzrmos/language-detector

Detect the language for your application using browser preferences, subdomains or route prefixes.

109554.8k3](/packages/vluzrmos-language-detector)[kerigard/laravel-lang-ru

Ru lang for Laravel

2116.8k](/packages/kerigard-laravel-lang-ru)[highsolutions/laravel-translation-manager

Manage Laravel Translations

1518.8k](/packages/highsolutions-laravel-translation-manager)[amendozaaguiar/laraveles-spanish-for-jetstream

Archivos de traducción al español latinoamericano para Laravel con Jetstream (auth, pagination, passwords, validation + todas las cadenas de Jetstream).

1412.1k](/packages/amendozaaguiar-laraveles-spanish-for-jetstream)

PHPackages © 2026

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