optimistdigital/nova-locale-manager

Laravel Nova tool to manage locales.

Maintainers

👁 Tarpsvo

Package info

github.com/outl1ne/nova-locale-manager

pkg:composer/optimistdigital/nova-locale-manager

Statistics

Installs: 7 091

Dependents: 0

Suggesters: 0

Stars: 16

Open Issues: 0

3.0.1 2022-07-18 06:18 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 8c3b246eda92892b631e3539c81b0c812b39d5f6

  • Tarvo Reinpalu <tarvoreinpalu.woop@gmail.com>
  • Kaspar Rosin <kaspar.rosin.woop@gmail.com>
  • Optimist Digital <info.woop@outl1ne.com>

managerlocalenovalaraveloutl1ne

This package is auto-updated.

Last update: 2026-06-06 12:41:31 UTC


README

👁 Latest Version on Packagist
👁 Total Downloads

This Laravel Nova package allows you to manage simple locales.

Features

  • Locale creation (name and slug)
  • Locale state management (active, default)

Requirements

  • php: >=8.0
  • laravel/nova: ^4.0

Installation

Install the package in a Laravel Nova project via Composer:

# Install nova-locale-manager
composer require outl1ne/nova-locale-manager

# Run migrations
php artisan migrate

Usage

nova_get_locales($activeOnly = false)

Parameter $activeOnly decides wether to return only active locales or all.

Returns the locales as a slug => name map.

[
 'en' => 'English',
 'et' => 'Estonian',
]

nova_get_locales_full($activeOnly = false)

Parameter $activeOnly decides wether to return only active locales or all.

Returns the locales and all their data.

[
 [
 'name' => 'English',
 'slug' => 'en',
 'active' => false,
 'default' => false,
 ],
 [
 'name' => 'Estonian',
 'slug' => 'et',
 'active' => true,
 'default' => true,
 ],
]

nova_get_default_locale()

Returns the default locale's full data.

[
 'name' => 'English',
 'slug' => 'en',
 'active' => false,
 'default' => false,
],

nova_get_default_locale_slug()

Returns the default locale's slug.

'en'

Handling locale deletion

You can get register a callback for when a locale is deleted using the NovaLocaleManager::deleteCallback() function. You can register the call back in NovaServiceProvider's boot() function.

Example:

// in app/Providers/NovaServiceProvider.php

public function boot()
{
 \Outl1ne\NovaLocaleManager\NovaLocaleManager::deleteCallback(function ($locale) {
 // $locale is the Locale model
 // Locale ID: $locale->id
 // Locale slug: $locale->locale
 // Locale name: $locale->name
 });
}

Configuration

The config file can be published using the following command:

php artisan vendor:publish --provider="Outl1ne\NovaLocaleManager\NovaLocaleManagerServiceProvider" --tag="config"

Credits

License

Nova Locale Manager is open-sourced software licensed under the MIT license.