Download the PHP package eklundkristoffer/js-localization without Composer

On this page you can find all versions of the php package eklundkristoffer/js-localization. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package js-localization

laravel-js-localization

Build Status Scrutinizer Code Quality Code Coverage Total Downloads

Simple, ease-to-use and flexible package for the Laravel web framework. Allows you to use localized messages of the Laravel webapp (see resources/lang directory) in your Javascript code. You may easily configure which messages you need to export.

⚠️ Looking for a new maintainer. Please contact me if you are interested.

Branches

Laravel Branch
5.x laravel-5
4.2 laravel-4.2
4.1 laravel-4.1 (near end of life)
4.0 laravel-4.0 (end of life)

Installation

Add the following line to the require section of your Laravel webapp's composer.json file:

Run composer update to install the package.

Finally add the following line to the providers array of your app/config/app.php file:

Configuration

Run php artisan vendor:publish first. This command copies the package's default configuration to config/js-localization.php.

You may now edit this file to define the messages you need in your Javascript code. Just edit the messages array in the config file.

Example (exports all reminder messages):

Important:

The messages configuration will be cached when the JsLocalizationController is used for the first time. After changing the messages configuration you will need to call php artisan js-localization:refresh to refresh that cache. That also affects the config properties you export to javascript, since they are cached, too.

Usage

The translation resources for JavaScript can either be served by your Laravel app at run-time or they can be pre-generated as static JavaScript files, allowing you to serve them straight from your web server or CDN or to be included in your build process.

Run-time generation

You just need to add the necessary <script> tags to your layout. Here is an example blade view:

Remember it's best to not put the @yield('js-localization.head') in the <head> as it contains the <script> tag shipping the frontend part of this package. It's best practice to put it at the end of the <body>, but before other <script> tags. The example above simply includes it in the head, since it's the simplest form to use it.

Static generation

For increased performance it is possible to generate static JavaScript files with all of your generated strings. These files can either be served directly as static files, or included as a part of your frontend asset build process.

To specify the output directory for the assets, just set the $storage_path string in your config/js-localization.php file accordingly (see Configuration).

The files can then be generated using the artisan command:

php artisan js-localization:export

This will generate two files in your target directory:

If you want to automatically split up the messages.js file into separate .js files for each locale, you can set the following to true in your config/js-localization.php config file:

This will in turn also generate the following file(s) in your target directory:

Remember that the files needs to be regenerated using php artisan js-localization:export every time any translation strings are edited, added or removed.

Features

You may use Lang.get(), Lang.has(), Lang.choice(), Lang.locale() and trans() (alias for Lang.get()) in your Javascript code. They work just like Laravel's Lang facade. Additionally, you are able to pass configuration properties to your Javascript code as well. There is Config.get() in Javascript, too. Configure which config properties to pass to the client using the config field in config/js-localization.php. Attention: Do not export any security-critical properties like DB credentials or similar, since they would be visible to anyone using your application!

Variables in messages are supported. For instance: "This is my test string for :name.".

Pluralization is also supported, but does not care about the locale. It only uses the English pluralization rule ("singular text|plural text"). More complex pluralization quantifiers are not yet supported.

Service providers

Assume you are developing a laravel package that depends on this javascript localization features and you want to configure which messages of your package have to be visible to the JS code.

Fortunately that's pretty easy. Just listen to the JsLocalization.registerMessages event and use the JsLocalization\Facades\JsLocalizationHelper::addMessagesToExport() method. Like so:

License

This software is released under the MIT license. See license.


All versions of js-localization with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 5.x
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package eklundkristoffer/js-localization contains the following files

Loading the files please wait ....