Download the PHP package longman/laravel-multilang without Composer

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

Laravel 5.x MultiLanguage

Build Status Code Coverage Code Quality Latest Stable Version Total Downloads Downloads Month

This version of MultiLang package requires minimum PHP 7.0. For older PHP versions use MultiLang 1.x

This is a very useful package to integrate multi language (multi locale) functionality in Laravel 5.x. It includes a ServiceProvider to register the multilang and Middleware for automatic modification routes like http://site.com/en/your-routes.

This package uses database for storing translations (it caches data on production environment for improving performance) Also package automatically adds in database missing keys (on the local environment only).

Table of Contents

Installation

Install this package through Composer.

Edit your project's composer.json file to require longman/laravel-multilang

Create composer.json file:

And run composer update

Or run a command in your command line:

composer require longman/laravel-multilang

In Laravel the service provider and facade will automatically get registered.

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="Longman\LaravelMultiLang\MultiLangServiceProvider"

After run multilang migration command

php artisan multilang:migration

Its creates multilang migration file in your database/migrations folder. After you can run

php artisan migrate

Also if you want automatically change locale depending on url (like http://site.com/en/your-routes) you must add middleware in app/Http/Kernel.php

I suggest add multilang after CheckForMaintenanceMode middleware

In your RoutesServiceProvider modify that:

or directly in app/Http/routes.php file add multilang group:

Or if you want only translate strings without automatic resolving locale and redirect, you can manually set locale in your application like:

Usage

Translating

Everywhere in application you can use t() helper function like:

You can use markers for dynamic texts and pass any data like

which will be return The Start Date must be a date after 7 April 1986.

Blade Templates

In blade templates you can use just @t() notation like

which is equivalent to {{ t('Your translatable string') }}

URL Generation

Also you can use lang_url() helper function for appending current lang marker in urls automatically.

You can force locale and get localized url for current url for example.

or

Also you use named routes via lang_route() function

Also Request::locale() always will return current locale.

Note: Texts will be selected after firing Laravel's LocaleUpdated event. Therefore you should use MultiLang middleware, or manually set locale in the application.

Text Scopes

If you want group translations by some scope, in package available defining of scopes. For example to define scope admin in application, you should call:

before setting the locale.

Note: Default scope is global

Import/Export Texts

For versioning texts with source code (git/svn) and easy management, there is possible import texts from yml file and also export in the file.

yml file format is:

Run commands for possible options and more information:

php artisan help multilang:import

php artisan help multilang:export

TODO

write more tests

Troubleshooting

If you like living on the edge, please report any bugs you find on the laravel-multilang issues page.

Contributing

Pull requests are welcome. See CONTRIBUTING.md for information.

License

Please see the LICENSE included in this repository for a full copy of the MIT license, which this project is licensed under.

Credits

Full credit list in CREDITS


All versions of laravel-multilang with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1.0
ext-mbstring Version *
symfony/yaml Version ^6.0
symfony/translation Version ^6.0
illuminate/console Version ^10.0
illuminate/support Version ^10.0
illuminate/database Version ^10.0
illuminate/http Version ^10.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 longman/laravel-multilang contains the following files

Loading the files please wait ....