Download the PHP package madbox-99/filament-translatable-model-labels without Composer

On this page you can find all versions of the php package madbox-99/filament-translatable-model-labels. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-translatable-model-labels

Filament Translatable Model Labels

Resolve Filament Resource model labels (singular and plural) — and therefore the navigation item and table heading — through Laravel's __() translation, keyed off the auto-derived model name. Define the translation once; every Resource picks it up without per-Resource overrides.

Installation

Usage

Apply the trait to a shared base Resource so it is never repeated:

Or extend the provided base class:

Add the translations to your app's lang/hu.json:

Result: the create button reads "Új probléma", and the navigation item and table heading read "Problémák".

Automatic injection on make:filament-resource

This works out of the box — no configuration needed. Once the package is installed, php artisan make:filament-resource adds the trait to every generated resource automatically. The generated class still extends the original Filament Resource; the package just adds the trait:

The trait is a no-op when no translation exists (it returns the stock label), so it is harmless even on resources you don't translate.

Turning it off

If you'd rather add the trait manually, publish the config and disable it:

Note: this hooks Filament's internal resource generator (Filament\Commands\FileGenerators\Resources\ResourceClassGenerator) via the container. It is a generation-time (dev) convenience with no runtime effect.

Retrofitting existing resources (Rector)

The generator integration only affects newly generated resources. To add the trait to all of your existing resources in one pass, use the bundled Rector rule.

Add it to your rector.php:

Then run it:

Every class that extends Filament\Resources\Resource and does not already use the trait gets use TranslatesFilamentModelLabels; added. Resources that already use it, and non-resource classes, are left untouched. Requires rector/rector in your project.

How it works

Multi-word models

The key is the humanised, lower-cased model name with spaces, e.g. BlogPost becomes __('blog post') / __('blog posts'):

Testing

License

MIT.


All versions of filament-translatable-model-labels with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
filament/filament Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package madbox-99/filament-translatable-model-labels contains the following files

Loading the files please wait ...