Download the PHP package alexjoffroy/laravel-localization without Composer

On this page you can find all versions of the php package alexjoffroy/laravel-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 laravel-localization

A Laravel package to handle localization from your routes

Latest Version on Packagist Build Status Code Coverage Quality Score Total Downloads

This Laravel package gives you the ability to simply handle localization in your application. It provides a set of helpers so you can basically do stuff like:

You can still continue to use Laravel core features such as testing, route caching, lang files, ...

Table of content

Installation

You can install the package via composer:

This package will automatically register itself.

Optionnaly, you can publish the config file config/localization.php:

If you want to customize the default switch view:

Configuration

Default locale

The default locale can be changed in the config file. By default, this value is the same as the Laravel fallback_locale (set in config/app.php).

Supported locales

You can list all locales you want to support here.

Each key should be a locale code (en, fr, ...).

The native field is the label which will be rendered in the switch view. regional_code, charset, and constants fields are required to work with PHP's setlocale, which is called in Localization::setLocale. This is useful for stuff like date formatting with Carbon.

Hide default locale in url

By default, all URLs will be prefixed with the locale.

When setting hide_default_locale_in_url to true, this prefix will be removed for the default locale.

Usage

Register the middleware

The first step is to register the SetLocaleFromCurrentRoute middleware into your app. This middleware will guess and set the current locale from the URL. The easiest way to do that is to register it globally:

Add your routes

You are now able to register your locales routes, with a convenient helper:

Warning: all routes defined inside the locales group should be named.

According you are supporting en and fr locales and you defined translations for routes.about, the above code will register these routes:

Verb URL Name Action
GET HEAD en/about en.about App\Http\Controllers\AboutController@index
GET HEAD fr/a-propos fr.about App\Http\Controllers\AboutController@index

The Localization instance

The \AlexJoffroy\Localization\Localization class provides a set of methods which could be helpful to use in your app. The object is registered as a singleton and can be accessed from the app container, the L10n facade or the l10n() helper.

Get/Set locale

Localization::getLocale and Localization::setLocale are aliases for App::getLocale and App::setLocale

Checks

Get config values

Generate routes

Render switch

This should be called in a Blade view like {{ l10n()->renderSwitch() }}. When using a custom view, you can directly access the Localization instance from $l10n variable.

Custom view example:

Facade

The Localization methods are also available from the L10n facade.

Helpers

Testing

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

This package was originally build on top of the package skeleton provided by Spatie at spatie/skeleton-php

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-localization with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
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 alexjoffroy/laravel-localization contains the following files

Loading the files please wait ....