optimistdigital/nova-locale-manager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

optimistdigital/nova-locale-manager

最新稳定版本:3.0.1

Composer 安装命令:

composer require optimistdigital/nova-locale-manager

包简介

Laravel Nova tool to manage locales.

README 文档

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.

统计信息

  • 总下载量: 6.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-26