outl1ne/nova-locale-manager
Nova Locale Manager
This Laravel Nova package allows you to manage simple locales.
Features
- Locale creation (name and slug)
- Locale state management (active, default)
Requirements
php: >=8.0laravel/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.
Related Packages
This Laravel Nova package helps developers load translations into their packages...
This Laravel Nova package helps developers load translations into their packages...
This Laravel Nova package allows you to reorder models in a Nova resource's inde...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.0.1 | >=8.0.0 | ^9.0 | MIT | |
| 3.0.0 | >=8.0.0 | ^9.0 | MIT | |
| 2.0.4 | >=7.1.0 | MIT | ||
| 2.0.3 | >=7.1.0 | MIT | ||
| 2.0.2 | >=7.1.0 | MIT | ||
| 2.0.1 | >=7.1.0 | MIT | ||
| 2.0.0 | >=7.1.0 | MIT | ||
| 1.0.5 | >=7.1.0 | MIT | ||
| 1.0.4 | >=7.1.0 | MIT | ||
| 1.0.3 | >=7.1.0 | MIT | ||
| 1.0.2 | >=7.1.0 | MIT | ||
| 1.0.1 | >=7.1.0 | MIT | ||
| 1.0.0 | >=7.1.0 | MIT |