PHPackages                             georgechaduneli/laravel-js-localization - 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. georgechaduneli/laravel-js-localization

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

georgechaduneli/laravel-js-localization
=======================================

Laravel Localization in JavaScript

091PHP

Since Aug 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/georgechaduneli/Laravel-JS-Localization)[ Packagist](https://packagist.org/packages/georgechaduneli/laravel-js-localization)[ RSS](/packages/georgechaduneli-laravel-js-localization/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel JS Localization
=======================

[](#laravel-js-localization)

> 🌐 Laravel Localization in JavaScript.

[![Laravel 5.3](https://camo.githubusercontent.com/43de799b2f52f81c3e5e05e15191e5192b26b55d0d16e70a803a8267136e75c8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e332d6634363435662e737667)](https://camo.githubusercontent.com/43de799b2f52f81c3e5e05e15191e5192b26b55d0d16e70a803a8267136e75c8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e332d6634363435662e737667)[![Laravel 5.2](https://camo.githubusercontent.com/6a2aecf819d46484be64d17c3356d388b6f3b3e914c18ac5d7f3578a935a2770/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e322d6634363435662e737667)](https://camo.githubusercontent.com/6a2aecf819d46484be64d17c3356d388b6f3b3e914c18ac5d7f3578a935a2770/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e322d6634363435662e737667)[![Laravel 5.1](https://camo.githubusercontent.com/debf3e02a29ed710a46e10243c0fd84e35d89608988b4aad68459fb0f0fae8f9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e312d6634363435662e737667)](https://camo.githubusercontent.com/debf3e02a29ed710a46e10243c0fd84e35d89608988b4aad68459fb0f0fae8f9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e312d6634363435662e737667)[![Laravel 5.0](https://camo.githubusercontent.com/93950e24fb94d83195fcaf0a71f2ad987eaf2e368c059f59b7ab8677284f0c44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e302d6634363435662e737667)](https://camo.githubusercontent.com/93950e24fb94d83195fcaf0a71f2ad987eaf2e368c059f59b7ab8677284f0c44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e302d6634363435662e737667)[![Laravel 4.2](https://camo.githubusercontent.com/5082187d110c7f214eb85535e944c5b50dddf182bb953161a7cd6fb616994f8c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d342e322d6634363435662e737667)](https://camo.githubusercontent.com/5082187d110c7f214eb85535e944c5b50dddf182bb953161a7cd6fb616994f8c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d342e322d6634363435662e737667)[![Latest Stable Version](https://camo.githubusercontent.com/2550cc9611b6821134bedef324eacaf7b81ad81c0b9727a97eeb8a65501ee166/68747470733a2f2f706f7365722e707567782e6f72672f6d617269757a7a6f2f6c61726176656c2d6a732d6c6f63616c697a6174696f6e2f762f737461626c652e737667)](https://packagist.org/packages/mariuzzo/laravel-js-localization)[![Total Downloads](https://camo.githubusercontent.com/ab3a29aabf737b5c9e412da9ea245d239957aa065a88505ffeae1944fb02e89d/68747470733a2f2f706f7365722e707567782e6f72672f6d617269757a7a6f2f6c61726176656c2d6a732d6c6f63616c697a6174696f6e2f646f776e6c6f6164732e737667)](https://packagist.org/packages/mariuzzo/laravel-js-localization)[![License](https://camo.githubusercontent.com/9c96bbd1682c47f71bcb1272136cf744e929e95c4ae5a808f5cf027812a45ee3/68747470733a2f2f706f7365722e707567782e6f72672f6d617269757a7a6f2f6c61726176656c2d6a732d6c6f63616c697a6174696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/mariuzzo/laravel-js-localization)[![Join the chat at https://gitter.im/rmariuzzo/Laravel-JS-Localization](https://camo.githubusercontent.com/abe08b740a4156153736f791393ec4da6619c4be73212e75769f52edacc0e2b5/68747470733a2f2f6261646765732e6769747465722e696d2f4a6f696e253230436861742e737667)](https://gitter.im/rmariuzzo/Laravel-JS-Localization?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

This package convert all your localization messages from your Laravel app to JavaScript with a small library to interact with those messages following a very similar syntax you are familiar with.

### Features

[](#features)

- Support Laravel 4.2.x, Laravel 5.0.x, Laravel 5.1.x, Laravel 5.2.x and Laravel 5.3.x.
- Includes [Lang.js](https://github.com/rmariuzzo/lang.js) (a thin library highly inspired on Laravel's [`Translator`](https://laravel.com/api/5.3/Illuminate/Translation/Translator.html) class).
- Allow to specify desired lang files to be converted to JS.
- Lang.js API is based on Laravel's [`Translator`](https://laravel.com/api/5.3/Illuminate/Translation/Translator.html) class. No need to learn a whole API.

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

[](#installation)

```
composer require mariuzzo/laravel-js-localization
```

In your Laravel app go to `config/app.php` and add the following service provider:

```
Mariuzzo\LaravelJsLocalization\LaravelJsLocalizationServiceProvider::class
```

Usage
-----

[](#usage)

The `Laravel-JS-Localization` package provides a command that generate the JavaScript version of all your messages found at: `app/lang` (Laravel 4) or `resources/lang` (Laravel 5) directory. The resulting JavaScript file will contains all your messages plus [Lang.js](https://github.com/rmariuzzo/lang.js) (a thin library highly inspired on Laravel's [`Translator`](https://laravel.com/api/5.3/Illuminate/Translation/Translator.html) class).

### Generating JS messages

[](#generating-js-messages)

```
php artisan lang:js
```

### Specifying a custom target

[](#specifying-a-custom-target)

```
php artisan lang:js public/assets/dist/lang.dist.js
```

### Compressing the JS file

[](#compressing-the-js-file)

```
php artisan lang:js -c
```

Configuration
-------------

[](#configuration)

First, publish the default package's configuration file running:

```
php artisan vendor:publish --provider="Mariuzzo\LaravelJsLocalization\LaravelJsLocalizationServiceProvider"
```

The configuration will be published to `config/localization-js.php`.

You may edit this file to define the messages you need in your Javascript code. Just edit the `messages` array in the config file. **Empty messages array will include all the language files in build**.

To make only `pagination.php` &amp; `validation.php` files to be included in build process:

```
