PHPackages                             michele-angioni/laravel-js-lang-converter - 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. michele-angioni/laravel-js-lang-converter

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

michele-angioni/laravel-js-lang-converter
=========================================

Laravel Localization in JavaScript

v3.1.0(8y ago)2565.2k↓50%8[1 issues](https://github.com/micheleangioni/laravel-js-lang-converter/issues)MITJavaScriptPHP &gt;=7.0

Since May 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/micheleangioni/laravel-js-lang-converter)[ Packagist](https://packagist.org/packages/michele-angioni/laravel-js-lang-converter)[ Docs](https://github.com/michele-angioni/laravel-js-lang-converter)[ RSS](/packages/michele-angioni-laravel-js-lang-converter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (22)Used By (0)

Laravel JS Lang Converter
=========================

[](#laravel-js-lang-converter)

> Laravel Localization in JavaScript.

[![Latest Stable Version](https://camo.githubusercontent.com/ea728b3c7ea64416cf8c5f86f6537ba92aeee037b8bc36f8abcb1ef755b6a89c/68747470733a2f2f706f7365722e707567782e6f72672f6d696368656c652d616e67696f6e692f6c61726176656c2d6a732d6c616e672d636f6e7665727465722f762f737461626c652e737667)](https://packagist.org/packages/michele-angioni/laravel-js-lang-converter)[![License](https://camo.githubusercontent.com/6b3a064a5502da2c22bf96dfbfcc3c7a19d58a502939230fe5055e8c7168b85b/68747470733a2f2f706f7365722e707567782e6f72672f6d696368656c652d616e67696f6e692f6c61726176656c2d6a732d6c616e672d636f6e7665727465722f6c6963656e73652e737667)](https://packagist.org/packages/michele-angioni/laravel-js-lang-converter)[![Build Status](https://camo.githubusercontent.com/d4e7f2f4f5ec90162e17719d8135e88a65d56cd68a5d7394ce2075e1d42c1d3d/68747470733a2f2f7472617669732d63692e6f72672f6d696368656c65616e67696f6e692f6c61726176656c2d6a732d6c616e672d636f6e7665727465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/micheleangioni/laravel-js-lang-converter)[![SensioLabsInsight](https://camo.githubusercontent.com/8ff5d93ef76334bfcdc5d4e4953ef5ed343a90362229e4b22c1c03d147965a38/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f62396333376138642d323661612d343538622d386537652d3763636163366431653032312f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/b9c37a8d-26aa-458b-8e7e-7ccac6d1e021)

Laravel JS Lang Converter converts all your localization messages of your Laravel app to JavaScript, providing a small JavaScript library to interact with those messages in the fron end.

Most of the work has been developed in [Mariuzzo's package ](https://github.com/rmariuzzo/laravel-js-localization)

Laravel 5.5+ is supported. PHP 7.0 is required. For Laravel 5.1 - 5-4 versions, use the v2.x branch.

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

[](#installation)

Add the following line to you `composer.json` file under `require`.

```
"michele-angioni/laravel-js-lang-converter": "~3.0"
```

and run `composer update` or `composer install`.

Then you need to add the Laravel JS Lang Converter service provider in your `app/config/app.php` file

```
'providers' => [
    // ...
    'MicheleAngioni\LaravelJsLangConverter\LaravelJsLangConverterServiceProvider',
    // ...
],
```

In order to use some package features, you need to publish the config file through the artisan command `php artisan vendor:publish`. It will create the `laravel_js_lang.php` file in your config directory.

Now you are done!

Usage
-----

[](#usage)

This project comes with a command that generate the JavaScript version of all your messages found in `resources/lang` directory. The resulting JavaScript file will have the whole bunch of messages and a thin library similar to Laravel's `Lang` class.

**Generating JS messages**

```
php artisan lang:js
```

**Specifying a custom target**

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

**Converting only some files**

If you don't want to convert ALL your lang files, you can specify the files you want to be converted into your `laravel_js_lang.php` conf file. Under the `files` array, just add the list of your source files, like so:

```
'files' => [
    'pagination',
    'validation'
]
```

**Compressing the JS file**

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

**Use [gulp](http://gulpjs.com/) to publish (optional):**

1. Install `gulp-shell` from  with `npm install --save-dev gulp-shell` .
2. Create an extension for elixir in your `gulpfile.js`:

    ```
    var shell = require('gulp-shell');

    //......

    var Task = elixir.Task;

    elixir.extend('langjs', function(path, minimize) {
        new Task('langjs', function() {
            var command = "php artisan lang:js " + (path || "public/js/messages.js");
                if (minimize) {
                    command += " -c";
                }
            return gulp.src("").pipe(shell(command));
        });
    });

    gulp.task('langJs', shell.task('php artisan lang:js -c public/js/messages.js'));
    ```
3. Use the new elixir task:

```
elixir(function(mix) {
    var path = "public/js";
    var minimize = true;
    mix.langjs(path, minimize);
});
```

Documentation
-------------

[](#documentation)

This is the documentation regarding the thin JavaScript library. The library is highly inspired on Laravel's `Lang` class.

**Getting a message**

```
Lang.get('messages.home');
```

**Getting a message with replacements**

```
Lang.get('messages.welcome', { name: 'Joe' });
```

**Changing the locale**

```
Lang.setLocale('es');
```

**Checking if a message key exists**

```
Lang.has('messages.foo');
```

**Support for singular and plural message based on a count**

```
Lang.choice('messages.apples', 10);
```

**Calling the `choice` method with replacements**

```
Lang.choice('messages.apples', 10, { name: 'Joe' });
```

For more detailed information, take a look at the source: [Lang.js](https://github.com/michele-angioni/laravel-js-lang-converter/blob/master/js/lang.js).

How to contribute
=================

[](#how-to-contribute)

Pull requests are welcome.

1. Fork this repository and clone it.
2. Create a branch from develop: `git checkout -b feature-foo`.
3. Push your commits and create a pull request.

Setting up development environment
----------------------------------

[](#setting-up-development-environment)

**Prerequisites:**

You need to have installed the following softwares.

- Composer
- NodeJS
- NPM
- PHP 7.0+

After getting all the required software you may run the following commands to get everything ready:

1. Install PHP dependencies:

```
composer install
```

2. Install NPM dependences:

```
npm install -g jasmine-node

npm install
```

Now you are good to go! Happy coding!

Unit testing
------------

[](#unit-testing)

This project use Jasmine-Node and PHPUnit. All tests are stored at `tests` directory.

To run all JS tests type in you terminal:

```
npm test
```

To run all PHP tests type in your terminal:

```
vendor/bin/phpunit tests/
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~92 days

Total

20

Last Release

3016d ago

Major Versions

v1.2.1 → v2.02016-01-17

v2.x-dev → v3.02017-09-11

PHP version history (5 changes)v1.0.0PHP &gt;=5.3.0

1.1.0PHP &gt;=5.4.0

v1.2.0PHP &gt;=5.5.9

v2.4PHP &gt;=5.6.4

v3.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ecc70cee36d2415684680df6e8278c83fc1345dd982bc59296bd8b0b4515160?d=identicon)[Michele](/maintainers/Michele)

---

Top Contributors

[![rmariuzzo](https://avatars.githubusercontent.com/u/439839?v=4)](https://github.com/rmariuzzo "rmariuzzo (46 commits)")[![micheleangioni](https://avatars.githubusercontent.com/u/7933034?v=4)](https://github.com/micheleangioni "micheleangioni (38 commits)")[![vluzrmos](https://avatars.githubusercontent.com/u/450848?v=4)](https://github.com/vluzrmos "vluzrmos (15 commits)")[![xAockd](https://avatars.githubusercontent.com/u/3390348?v=4)](https://github.com/xAockd "xAockd (9 commits)")[![gpopoteur](https://avatars.githubusercontent.com/u/952557?v=4)](https://github.com/gpopoteur "gpopoteur (7 commits)")[![okaufmann](https://avatars.githubusercontent.com/u/4414498?v=4)](https://github.com/okaufmann "okaufmann (5 commits)")[![matthew-sycle](https://avatars.githubusercontent.com/u/13425073?v=4)](https://github.com/matthew-sycle "matthew-sycle (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")[![eossa](https://avatars.githubusercontent.com/u/16960004?v=4)](https://github.com/eossa "eossa (1 commits)")[![antonkomarev](https://avatars.githubusercontent.com/u/1849174?v=4)](https://github.com/antonkomarev "antonkomarev (1 commits)")

---

Tags

internationalizationjavascriptlaravellocalizationphplaravellocalizationi18njavascriptJSlaravel 5lang

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michele-angioni-laravel-js-lang-converter/health.svg)

```
[![Health](https://phpackages.com/badges/michele-angioni-laravel-js-lang-converter/health.svg)](https://phpackages.com/packages/michele-angioni-laravel-js-lang-converter)
```

###  Alternatives

[mariuzzo/laravel-js-localization

Laravel Localization in JavaScript

6073.9M3](/packages/mariuzzo-laravel-js-localization)[pmochine/laravel-tongue

🎉 Finally a subdomain localization that works how you want it to work. 🌐

4158.4k](/packages/pmochine-laravel-tongue)[jayesh/laravel-gemini-translator

An interactive command to extract and generate Laravel translations using Gemini AI.

691.7k1](/packages/jayesh-laravel-gemini-translator)[zachleigh/laravel-lang-bundler

Create Laravel translations bundles.

2512.5k](/packages/zachleigh-laravel-lang-bundler)

PHPackages © 2026

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