PHPackages                             lankhaar/laravel-multilingual - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. lankhaar/laravel-multilingual

ActiveLibrary[Localization &amp; i18n](/categories/localization)

lankhaar/laravel-multilingual
=============================

Add a language switcher to your multilingual Laravel application

211PHP

Since Jun 21Pushed 4y ago2 watchersCompare

[ Source](https://github.com/lankhaar/laravel-multilingual)[ Packagist](https://packagist.org/packages/lankhaar/laravel-multilingual)[ RSS](/packages/lankhaar-laravel-multilingual/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Configurable language switcher delivered to your multilingual laravel application
---------------------------------------------------------------------------------

[](#configurable-language-switcher-delivered-to-your-multilingual-laravel-application)

- [Installation](#installation)
- [Usage](#usage)
    - [Configure available locales](#configure-available-locales)
    - [Display language switcher in navigation](#display-language-switcher-in-navigation)
    - [How to create your own language switcher layout](#create-your-own-language-switcher-layout)
- [Testing](#testing)
- [Changelog](#changelog)
- [Supported features](#supported-features)
- [Advanced configurations](#supported-features)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require lankhaar/laravel-multilingual
```

Then publish the configurations:

```
php artisan vendor:publish --provider="Lankhaar\Multilingual\MultilingualServiceProvider"
```

Usage
-----

[](#usage)

### Configure available locales

[](#configure-available-locales)

You can edit the config/multilingual.php file to configure the available locales as follows:

```
    'availableLocales' => [
        'en' => 'English',
        'nl' => 'Dutch',
    ],
```

### Display language switcher in navigation

[](#display-language-switcher-in-navigation)

The current language switcher is only compatible with bootstrap navbars. If you're not using bootstrap in your project, you can easily [create your own layout for it](#create-your-own-language-switcher-layout). If you are using bootstrap, just call `@multilingualSwitcher` in your navbar like this:

```

            {{ __('Home') }}

            {{ __('About') }}

            {{ __('Services') }}

            {{ __('Contact') }}

        @multilingualSwitcher

```

### Create your own language switcher layout

[](#create-your-own-language-switcher-layout)

As stated earlier, the standard layout shipped with the package is specifically designed to fit in a bootstrap navigation. If you aren't using bootstrap, you're probably better off creating your own layout.

Create a file in your project at `resources/views/vendor/laravel-multilingual/language-switcher.blade.php`to overwrite the existing language switcher template. See code snippet below for an example on how to loop over the available locales and link to them.

```
@if(count($locales = getMultilingualLocales()) > 1)

        {{ __('Language') }}

            @foreach($locales as $locale => $label)
                {{ __($label) }}
            @endforeach

@endif
```

Now you can call it wherever you want with the `@multilingualSwitcher` blade directive

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

### Supported features

[](#supported-features)

Feel free to creat issues for feature requests!

- Support languages per session (No changes in domain or URL structure);
- Support languages per domain (`example.com`, `example.nl`);
- Support languages in url (`/en/example`, `/nl/example`);

### Advanced config

[](#advanced-config)

```
/*
 * Define the default locale.
 */
'defaultLocale' => env('LOCALE_DEFAULT', 'en'),

/*
 * Define the locale identifier type.
 *
 * Possible values:
 * - session: Locale chosen by the user is stored in the session;
 * - domain: Domain will switch based of chosen locale (domains can be configured in localeDomains config);
 * - url: URL's change based of the chosen locale (routes will be prefixed with the locale like /en/example or /nl/example);
 */
'localeIdentifierType' => env('LOCALE_IDENTIFIER_TYPE', 'session'),

/*
 * Configure the available locales for your application.
 * Define as an array with locale as array key and label in language switcher as array value.
 */
'availableLocales' => [
    'en' => 'English',
    'nl' => 'Dutch',
],

/*
 * Locale domains (only used when localeIdentifierType is set to domain).
 */
'localeDomains' => [
    'en' => env('LOCALE_EN_DOMAIN_URL', 'example.com'),
    'nl' => env('LOCALE_NL_DOMAIN_URL', 'example.nl'),
],
```

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8080910de9efeed81c922fa3ed04cbd53d221afaf055ac416f64b98930706f6?d=identicon)[lankhaardevelopment](/maintainers/lankhaardevelopment)

---

Top Contributors

[![lankhaar](https://avatars.githubusercontent.com/u/107768491?v=4)](https://github.com/lankhaar "lankhaar (2 commits)")

### Embed Badge

![Health badge](/badges/lankhaar-laravel-multilingual/health.svg)

```
[![Health](https://phpackages.com/badges/lankhaar-laravel-multilingual/health.svg)](https://phpackages.com/packages/lankhaar-laravel-multilingual)
```

###  Alternatives

[smarty-gettext/smarty-gettext

Gettext plugin enabling internationalization in Smarty Package files

752.5M8](/packages/smarty-gettext-smarty-gettext)[devaslanphp/auto-translate

Auto generate translation JSON files

6627.3k](/packages/devaslanphp-auto-translate)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
