This Laravel Nova package allows you to manage simple locales.
- Locale creation (name and slug)
- Locale state management (active, default)
php: >=8.0
laravel/nova: ^4.0
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
Parameter $activeOnly
decides wether to return only active
locales or all.
Returns the locales as a slug => name
map.
[
'en' => 'English',
'et' => 'Estonian',
]
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,
],
]
Returns the default locale's full data.
[
'name' => 'English',
'slug' => 'en',
'active' => false,
'default' => false,
],
Returns the default locale's slug.
'en'
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
});
}
The config file can be published using the following command:
php artisan vendor:publish --provider="Outl1ne\NovaLocaleManager\NovaLocaleManagerServiceProvider" --tag="config"
Nova Locale Manager is open-sourced software licensed under the MIT license.