Download the PHP package swayok/laravel-language-detector without Composer

On this page you can find all versions of the php package swayok/laravel-language-detector. 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-language-detector

Laravel Language Detector

Join the chat at https://gitter.im/vluzrmos/laravel-language-detector

Latest Stable Version Total Downloads License

Build Status Scrutinizer Code Quality Code Climate Codacy Badge StyleCI

This package provides an easy way to detect and apply the language for your application using route prefixes.

Installation

Require the package using composer:

composer require vluzrmos/language-detector

Add the service provider as follows:

Laravel

Edit your config/app.php:

Insert this line of code above the listed RouteServiceProvider, ex:

::class notation is optional.

Lumen

Edit the bootstrap/app.php:

::class notation is optional.

Configuration

Two options for Laravel, either publish the package configuration using:

php artisan vendor:publish

then edit the new config/lang-detector.php file or add the following lines to your .env file:

If you not want to use that, just publish the configurations of the package with php artisan vendor:publish and edit on config/lang-detector.php generated.

For Lumen, consider to copy vendor/vluzrmos/language-detector/config/lang-detector.php to your configs dir and use $app->configure('lang-detector') before register the LanguageDetectorServiceProvider.

Detector Drivers

There are a few drivers that you might to use, choose one which matches with your application design:

Browser Preferences

The driver browser will try to detect the language of the application based on the request languages (browser preferences). This driver doesn't need any other configuration, just configure the available languages.

Subdomains

The driver subdomain will try to detect the language of the application which matches with subdomain of the hostname. eg.:

http://fr.site.domain

The subdomain driver will detect language fr and set the application to fr if it is one of the available languages in the lang-detector config file.

Note: subdomain and uri drivers require aliases of the the language-locales in the lang-detector config file.

Route Prefixes

The driver uri will try to detect the language based on the route prefix:

http://site.domain/en-us/home

That driver will detect en-us and set it to the application. (Note: Consider to aliase that locale)

And don't worry, if the url is like:

http://site.domain/home

The language will not be changed, the application will use your default language configured on your config/app.php file.

With uri driver, your route group needs be like this:

Issue: Lumen 5.0 doesn't support route prefix with empty strings, you should use that script:

Note: That is only for Lumen 5.0, the newest version (5.1) already fixes it.

Aliasing language locales

You might to use the style lang_LOCALE or just lang on your resources/lang dir. The language detector driver you have chosen will try to detect the language which matches with lang or lang_LOCALE available on your config/lang-detector.php.

example:

If you are not following that style of languages names or if you are using the subdomain or uri drivers, just configure it on config/lang-detector.php file:

or if you are using .env instead of config file:

Suggestions

The default Laravel language lines are available translated into 51 languages here:

If you want to translate your models you can use this package:

License

MIT.


All versions of laravel-language-detector with dependencies

PHP Build Version
Package Version
Requires illuminate/config Version ~5.0
illuminate/translation Version ~5.0
illuminate/support Version ~5.0
illuminate/cookie Version ~5.0
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 swayok/laravel-language-detector contains the following files

Loading the files please wait ....