Download the PHP package fortranlee/laravel-js-localization without Composer
On this page you can find all versions of the php package fortranlee/laravel-js-localization. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fortranlee/laravel-js-localization
More information about fortranlee/laravel-js-localization
Files in fortranlee/laravel-js-localization
Package laravel-js-localization
Short Description Laravel Localization in JavaScript
License MIT
Homepage https://github.com/rmariuzzo/laravel-js-localization
Informations about the package laravel-js-localization
Laravel JS Localization
🌐 Laravel Localization in JavaScript.
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
- 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 (a thin library highly inspired on Laravel's
Translator
class). - Allow to specify desired lang files to be converted to JS.
- Lang.js API is based on Laravel's
Translator
class. No need to learn a whole API.
Installation
In your Laravel app go to config/app.php
and add the following service provider:
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 (a thin library highly inspired on Laravel's Translator
class).
Generating JS messages
Specifying a custom target
Compressing the JS file
Configuration
First, publish the default package's configuration file running:
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
& validation.php
files to be included in build process:
Using gulp (optional)
Install gulp-shell
and then run it directly in your gulpfile.js
:
Using Laravel's elixir (optional)
Before Elixir 4.0:
Elixir 4.0+:
And use it like this:
Documentation
This is a quick documentation regarding Lang.js (the thin JavaScript library included by Laravel-JS-Localization
). The Lang.js (a thin library highly inspired on Laravel's Translator
class).
💁 Go to Lang.js documentation to see all available methods.
Getting a message
Getting a message with replacements
Changing the locale
Checking if a message key exists
Support for singular and plural message based on a count
Calling the choice
method with replacements
💁 Go to Lang.js documentation to see all available methods.
Want to contribute?
- Fork this repository and clone it.
- Create a feature branch from develop:
git checkout develop; git checkout -b feature-foo
. - Push your commits and create a pull request.
Prerequisites:
You will need to have installed the following softwares.
- Composer.
- PHP 5.5+.
Development setup
After getting all the required softwares you may run the following commands to get everything ready:
-
Install PHP dependencies:
- Install test dependencies:
Now you are good to go! Happy coding!
Testing
This project uses PHPUnit. All tests are stored at tests
directory. To run all tests type in your terminal:
All versions of laravel-js-localization with dependencies
illuminate/config Version >=4.2
illuminate/console Version >=4.2
illuminate/filesystem Version >=4.2
tedivm/jshrink Version 1.0.*