PHPackages                             mralgorithm/laravel-js-lang - 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. mralgorithm/laravel-js-lang

ActiveLibrary

mralgorithm/laravel-js-lang
===========================

laravel localization for javascript

12.8k1[1 issues](https://github.com/mralgorithm2000/laravel-js-lang/issues)JavaScript

Since Oct 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mralgorithm2000/laravel-js-lang)[ Packagist](https://packagist.org/packages/mralgorithm/laravel-js-lang)[ RSS](/packages/mralgorithm-laravel-js-lang/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-js-lang
===============

[](#laravel-js-lang)

laravel localization for javascript

use laravel `__()` function in javascript with same syntax

installation
============

[](#installation)

to install this package run:

```
composer require mralgorithm/laravel-js-lang

```

then run this command to publish required files:

```
php artisan vendor:publish --tag=laravel-js-lang

```

to create json files from your `lang` directory run this command:

```
php artisan JsLang:update

```

for the last step, add this script to your template file eather to use `JS` functions

```

```

functions
=========

[](#functions)

1. `__()`:
----------

[](#1-__)

function \_\_(key,replace = '',locale = ''){}

as you can see, this function take three parameters(key,replace,locale) that key is necessary and others(replace,locale) is optional. this function return the translation(if exist!) or the key if the translation does not exist.

### example

[](#example)

1. `__('auth.failed')`
2. `__('hello i am mralgorithm!')`
3. `__('auth.throttle',{seconds:'50'})`
4. `__('auth.failed','','fa')`

for more detail please read [Laravel Localization Document](https://laravel.com/docs/9.x/localization)

2. `lang_getLocale()`:
----------------------

[](#2-lang_getlocale)

take no parameters

return current Locale

### example

[](#example-1)

- `lang_getLocale()`

> en

3. `lang_setLocale()`
---------------------

[](#3-lang_setlocale)

take Locale

return void

### example

[](#example-2)

- `lang_getLocale()`

> en

- `lang_setLocale('fa')`
- `lang_getLocale()`

> fa

4. `is_locale()`:
-----------------

[](#4-is_locale)

take Locale

return true if Locale equal to Locale parameter and false in otherwise

### example

[](#example-3)

- `lang_setLocale('en')`
- `is_locale('fa')`

> false

- `is_locale('en')`

> true

Commands
========

[](#commands)

1. `JsLang:update`;
-------------------

[](#1-jslangupdate)

this command convert your `Lang` directory to `JSON` files so JavaScript can use them

**run this command whenever you make a change in your `Lang` directory**

`php artisan JsLang:update`

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bbd25e873423bbde5809e0a5329e14a965d995c97010b6d68b34139dd70d165f?d=identicon)[mralgorithm](/maintainers/mralgorithm)

---

Top Contributors

[![mmohammadrezaa](https://avatars.githubusercontent.com/u/29540296?v=4)](https://github.com/mmohammadrezaa "mmohammadrezaa (9 commits)")[![mralgorithm2000](https://avatars.githubusercontent.com/u/114799598?v=4)](https://github.com/mralgorithm2000 "mralgorithm2000 (3 commits)")

### Embed Badge

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

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

PHPackages © 2026

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