PHPackages                             youneselbarnoussi/nova-locale-switcher - 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. youneselbarnoussi/nova-locale-switcher

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

youneselbarnoussi/nova-locale-switcher
======================================

A simple locale switcher for Nova without any concrete localization implementation

0338Vue

Since Mar 29Pushed 3y agoCompare

[ Source](https://github.com/YouneselBarnoussi/nova-locale-switcher)[ Packagist](https://packagist.org/packages/youneselbarnoussi/nova-locale-switcher)[ RSS](/packages/youneselbarnoussi-nova-locale-switcher/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Nova Locale Switcher Tool
=================================

[](#laravel-nova-locale-switcher-tool)

This tool provides a simple header dropdown to quickly switch between locales. This tool does not have any concrete implementation, so is up to you of what happens when a locale is selected from the dropdown.

[![Nova Locale Switcher](https://raw.githubusercontent.com/Eolica-Web/nova-locale-switcher/master/docs/screenshots/screenshot_1.png)](https://raw.githubusercontent.com/Eolica-Web/nova-locale-switcher/master/docs/screenshots/screenshot_1.png)

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

[](#installation)

```
composer require eolica/nova-locale-switcher
```

If you were using our `tramuntana-studio/nova-locale-switcher` package, please modify it accordingly.

Usage
-----

[](#usage)

We will demonstrate how tu use this tool with a simple example. First, you must register the tool in `NovaServiceProvider` under tools.

```
use Illuminate\Http\Request;

public function tools()
{
    return [
        \Eolica\NovaLocaleSwitcher\LocaleSwitcher::make()
            ->setLocales(config('nova.locales'))
            ->onSwitchLocale(function (Request $request) {
                $locale = $request->post('locale');

                if (array_key_exists($locale, config('nova.locales'))) {
                    $request->user()->update(['locale' => $locale]);
                }
            }),
    ];
}
```

The `setLocales` method expects an associative array, the key being the locale code and the value the name of the locale. In this example, we set the locales from de `nova.php` config file:

```
return [

    // Rest of Nova configuration

    ...

    /*
    |--------------------------------------------------------------------------
    | Nova Locales
    |--------------------------------------------------------------------------
    */

    'locales' => [
        'en' => 'English',
        'de' => 'Deutsch',
        'es' => 'Español',
    ],
];
```

For handling the locale switching we must pass a `callable` to the `onSwitchLocale` method, in this example we update the current user locale field (this is a custom field that we added to the model) with the locale that we receive from the Request object.

Now, for setting the application locale we can do it inside the `boot` method of the `NovaServiceProvider` by using the `Nova::serving()` method:

```
use Laravel\Nova\Events\ServingNova;

final class NovaServiceProvider extends NovaApplicationServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        Nova::serving(function (ServingNova $event) {
            $user = $event->request->user();

            if (array_key_exists($user->locale, config('nova.locales'))) {
                app()->setLocale($user->locale);
            }
        });
    }

    ...
}
```

The last step is to display the language selector. For that we must [publish](https://nova.laravel.com/docs/3.0/installation.html#updating-nova-s-assets) Nova's views executing the next command:

```
php artisan nova:publish
```

Now we go to the file `/resources/views/vendor/nova/layout.blade.php` and right after the dropdown that includes the user's partial we add the `locale-switcher` Vue component:

```

    ...

        @include('nova::partials.user')

```

And that should be it!

This is one of many solutions you can use, the important thing is that you can switch to another type of implementation without depending on an external package.

Changelog
---------

[](#changelog)

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

Security
--------

[](#security)

If you discover a security vulnerability within this package, please send an email at  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity23

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://avatars.githubusercontent.com/u/16510310?v=4)[Younes el Barnoussi](/maintainers/YouneselBarnoussi)[@YouneselBarnoussi](https://github.com/YouneselBarnoussi)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/youneselbarnoussi-nova-locale-switcher/health.svg)

```
[![Health](https://phpackages.com/badges/youneselbarnoussi-nova-locale-switcher/health.svg)](https://phpackages.com/packages/youneselbarnoussi-nova-locale-switcher)
```

PHPackages © 2026

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