apility/filament-localizable-resources

This package provides a re-usable trait for Filament Resources which adds support for localizing the resource labels.

v1.0.2 2024-01-17 08:46 UTC

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This package provides a re-usable trait for Filament Resources which adds support for localizing the resource labels.

Installation

You can install the package via composer:

composer require apility/filament-localizable-resources

Usage

namespace App\Filament\Resources;

use Apility\Filament\Concerns\HasLocalizableResourceLabels;

use Filament\Resources\Resource;

class ArticleResource extends Resource
{
    use HasLocalizableResourceLabels;

    // ...
}

The trait modifies the default methods for retrieving the resource labels to use the __() helper function to translate the labels.

It will look for the translation key in the following format:

lang/<locale>/resources.php

return [
    // The resource slug is used as the translation key
    'articles' => [
        'model_label' => 'article|articles',
        'navigation_label' => 'Articles', // Optional, defaults to model_label
        'slug' => 'articles', // Optional, will use model_label as fallback
    ],
];

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.