Download the PHP package spatie/nova-translatable without Composer

On this page you can find all versions of the php package spatie/nova-translatable. 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 nova-translatable

Making Nova fields translatable

Latest Version on Packagist GitHub Workflow Status Check & fix styling Total Downloads

This package contains a Translatable class you can use to make any Nova field type translatable.

Imagine you have this fields method in a Post Nova resource:

That Post Nova resource will be rendered like this.

screenshot

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Requirements

This Nova field requires Nova 3 specifically and MySQL 5.7.8 or higher.

Installation

First you must install spatie/laravel-translatable into your Laravel app. In a nutshell, this package will store translations for your model in a json column in your table. On top of that, it provides many handy functions to store and retrieve translations. Be sure to read the entire readme of laravel-translatable before using this Nova package.

Next, you can install this Nova package into a Laravel app that uses Nova via composer:

Usage

In order to use the package you must first let Translatable know which locales your app is using using the Translatable::defaultLocales() method. You can put this code in AppServiceProvider or a dedicated service provider of your own.

Next, you must prepare your model as explained in the readme of laravel-translatable. In short: you must add json columns to your model's table for each field you want to translate. Your model must use the Spatie\Translatable\HasTranslations on your model. Finally, you must also add a $translatable property on your model that holds an array with the translatable attribute names.

Now that your model is configured for translations, you can use Translatable in the related Nova resource. Any fields you want to display in a multilingual way can be passed as an array to `Translatable.

Making translations searchable

Every translation of the translated fields should be added into the $search array separately.

Customizing the locales per translatable

If you have a Nova resource where you want different locales than the ones configured globally, you can call the locales method on Translatable.

These fields will now use the de and es locales.

Customizing the name of a translatable

By default translatable fields get ($locale) appended to their name. You can customize this behaviour globally by providing a closure to displayLocalizedNameByDefaultUsing on Translatable. This callback will be used to render the localized field names.

With this in place all names of translatable fields will get [$locale] appended.

You can also customize the localized field name per resource by passing a closure the displayLocalizedNameUsing function.

With this in place, the localized field names will be suffixed with --- $locale.

Of course you can still customize the name of a field as usual.

Using the code about above the name for the title field will be "My title ['en']".

Customizing the rules of a translatable

You may use the regular Nova functionality to define rules on the fields inside your Translatable fields collection. However, this will apply those rules to all locales. If you wish to define different rules per locale you can do so on the Translatable collection.

You may also use the more fluent rulesFor() method, which allows you to define rules per field per locale.

There are also methods for update and creation rules called creationRules(), updateRules(), creationRulesFor() and updateRulesFor(). They function in the same way as the rules() and rulesFor() methods.

On customizing the UI

You might wonder why we didn't render the translatable fields in tabs, panels or with magical unicorns displayed next to them. The truth is that everybody wants translations to be displayed a bit different. That's why we opted to keep them very simple for now.

If Nova gains the ability to better structure a long form natively, we'd probably start leveraging that in a new major version of the package.

Testing

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Credits

License

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


All versions of nova-translatable with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3|^8.0
laravel/nova Version ^4.0
spatie/laravel-translatable Version ^5.0|^6.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 spatie/nova-translatable contains the following files

Loading the files please wait ....