Download the PHP package abdiwaahid/language-switcher without Composer

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

Simple and Flexible Language Switcher for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A simple language switcher for your Laravel applications. This package provides an easy way to allow your users to switch between different languages, with support for both session and cache drivers to store the selected locale. It also includes a ready-to-use Blade component for a seamless frontend integration.

Features

Requirements

Installation

You can install the package via composer:

You can publish the config file with:

This is the contents of the published config file:

Optionally, you can publish the views using

You can also publish the translation files to add support for more languages or customize the existing ones:

Finally, to use the provided CSS and JavaScript for the Blade component, publish the assets:

This will place a stylesheet and a script in your public/vendor/language-switcher directory.

Usage

1. Configure Your Languages

First, you need to define the languages you want to support in the config/language-switcher.php file. For example:

or you can simply configure the languages in the AppServiceProvider:

2. Add the Middleware

The package automatically registers the middleware for you. but if you want to add it manually, you can register it manually in your bootstrap/app.php file:

3. Add Styles and Scripts

For the dropdown component to function and look its best, include the published assets in your main layout file (resources/views/layouts/app.blade.php or similar).

The package provides two helpful Blade directives for this:

4. Use the Blade Component

The package comes with a ready-to-use Blade component to display the language switcher in your views. You can use it like this:

This will render a dropdown with the list of available languages. When a user clicks on a language, it will switch the application's locale and store it in the configured driver.

5. Usage with FilamentPHP

To integrate the language switcher with a FilamentPHP admin panel, you can register the component and its assets within the service provider.

First, make sure you have published the package assets:

Then, in the register method of your service provider, add the following:

This will:

  1. Load the necessary CSS and JavaScript for the dropdown component.
  2. Configure the available languages for the switcher.
  3. Render the language switcher component right before the default user menu in the Filament panel.

Advanced Usage

Facade

The package provides a LanguageSwitcher facade for more granular control.

Set the current locale: This will update the locale in the configured storage driver (session or cache).

Get the current locale:

This retrieves the locale from the storage driver.

Get available languages:

This returns a collection of all configured languages, excluding the current one. This is useful for building a custom language switcher UI.

Artisan Command

You can inspect the current locale and all configured languages using the bundled Artisan command:

Driver Configuration

In the config/language-switcher.php file, you can choose the storage driver.

Customization

If you need to modify the look and feel of the language switcher, you can publish the views:

The view files will be located in resources/views/vendor/language-switcher. You can edit them as you see fit.

You can also publish the translation files to customize the language names displayed in the dropdown for different locales:

This will create translation files in resources/lang/vendor/language-switcher.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of language-switcher with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0||^13.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 abdiwaahid/language-switcher contains the following files

Loading the files please wait ...