hosteeka / laravel-lang
Use your Laravel translations in JavaScript.
dev-main
2025-03-21 21:44 UTC
Requires
- php: >=8.1
- ext-json: *
- laravel/framework: >=9.0
Requires (Dev)
- laravel/pint: ^1.21
- orchestra/testbench: ^10.1
- pestphp/pest: ^3.7
- pestphp/pest-plugin-laravel: ^3.1
This package is auto-updated.
Last update: 2025-07-21 22:27:58 UTC
README
This package is heavily inspired by Ziggy which enables you to use your Laravel routes in JavaScript.
Installation
You can install the package via composer:
composer require hosteeka/laravel-lang
Usage
Generate the JavaScript file with the translations:
php artisan lang:generate
This will create a resources/js/lang.js
file with the translations:
// resources/js/lang.js const Lang = { "defaultLocale": "es", "fallbackLocale": "en", "supportedLocales": { "en": "English", "es": "EspaƱol" }, "translations": { "en": { "welcome": { "getting_started": "Let's get started :name" }, "Laravel has an incredibly rich ecosystem.": "Laravel has an incredibly rich ecosystem." }, "es": { "welcome": { "getting_started": "Empecemos :name" }, "Laravel has an incredibly rich ecosystem.": "Laravel tiene un ecosistema increĆblemente rico." } } }
To pass a custom path to generate the file, you can run the following command:
php artisan lang:generate public/js/lang.js