All Projects → mrmonat → nova-translatable

mrmonat / nova-translatable

Licence: other
Nova Field for spatie/laravel-translatable package.

Programming Languages

Vue
7211 projects
PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

Projects that are alternatives of or similar to nova-translatable

nova-rating-field
A Star rating field to use in your Laravel Nova apps.
Stars: ✭ 42 (-50%)
Mutual labels:  laravel-nova
nova-qrcode-field
A Laravel Nova field to generate QR Code
Stars: ✭ 28 (-66.67%)
Mutual labels:  laravel-nova
nova-horizon-stats
Nova cards for Laravel applications that use Laravel Horizon
Stars: ✭ 31 (-63.1%)
Mutual labels:  laravel-nova
nova-list-card
Add a variety of resource lists to Nova dashboards
Stars: ✭ 39 (-53.57%)
Mutual labels:  laravel-nova
nova-table-field
Table field for Laravel Nova
Stars: ✭ 29 (-65.48%)
Mutual labels:  laravel-nova
nova-system-resources
Display the system usage in Laravel-Nova
Stars: ✭ 30 (-64.29%)
Mutual labels:  laravel-nova
Lang
List of 78 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.
Stars: ✭ 6,285 (+7382.14%)
Mutual labels:  laravel-nova
nova-inspire
The best way to connect with your customers is by reaching out and inspiring them. ~ Me
Stars: ✭ 14 (-83.33%)
Mutual labels:  laravel-nova
nova-dynamic-field
Dynamic field for Laravel Nova
Stars: ✭ 18 (-78.57%)
Mutual labels:  laravel-nova
nova-html
This field allows you display custom HTML in Laravel Nova, be it a link, an image or any other piece of proper html.
Stars: ✭ 13 (-84.52%)
Mutual labels:  laravel-nova
nova-conditional-fields
WIP: Conditionally display fields based on another field's value
Stars: ✭ 38 (-54.76%)
Mutual labels:  laravel-nova
nova-opcache
OPcache Tool for Laravel Nova
Stars: ✭ 21 (-75%)
Mutual labels:  laravel-nova
nova-sluggable
Slug field for Laravel Nova
Stars: ✭ 40 (-52.38%)
Mutual labels:  laravel-nova
nova-gridder
Customize Nova Resource Details using Tailwind Grid System and more
Stars: ✭ 18 (-78.57%)
Mutual labels:  laravel-nova
select-auto-complete
An auto-completing Laravel Nova search field
Stars: ✭ 34 (-59.52%)
Mutual labels:  laravel-nova
nova-errors
Display all form errors in a modal at the top of the page.
Stars: ✭ 16 (-80.95%)
Mutual labels:  laravel-nova
nova-blogify-tool
Create a simple blog in a few seconds. Powered by Laravel Nova.
Stars: ✭ 20 (-76.19%)
Mutual labels:  laravel-nova
nova-grouped-field
Combine multiple Nova fields as one field output
Stars: ✭ 43 (-48.81%)
Mutual labels:  laravel-nova
nova-url-field
A URL input and link field for Laravel Nova
Stars: ✭ 96 (+14.29%)
Mutual labels:  laravel-nova
laravel-nova-order-nestedset-field
Laravel Nova field that make your resources orderable
Stars: ✭ 21 (-75%)
Mutual labels:  laravel-nova

Important

This package will no longer be maintained. Please use https://github.com/spatie/nova-translatable as a replacement. If you do not like the different approach of the spatie package, feel free to fork this repository and release new versions of it.

Nova Translatable Field

Latest Version on Packagist

Adds the ability to show and edit translated fields created with spatie/laravel-translatable package.

It will show up in the detail view like this:

And in the edit view like this:

Alternative with support for more field types

If you need support for more field types to be translated, take a look at the official package from spatie: https://github.com/spatie/nova-translatable

Installation and usage

You can require this package using composer:

composer require mrmonat/nova-translatable

You can add the field follows:

use MrMonat\Translatable\Translatable;

Translatable::make('Description'),

Make sure, that you have your Eloquent model setup correct:

  • First, you need to add the Spatie\Translatable\HasTranslations-trait.
  • Next, you should create a public property $translatable which holds an array with all the names of attributes you wish to make translatable.
  • Finally, you should make sure that all translatable attributes are set to the text-datatype in your database. If your database supports json-columns, use that.

Here's an example of a prepared model:

use Illuminate\Database\Eloquent\Model;
use Spatie\Translatable\HasTranslations;

class NewsItem extends Model
{
    use HasTranslations;
    
    public $translatable = ['name'];
}

Defining Locales

Locales can be defined via config file config/translatable.php (config file can be created via spatie/laravel-translatable package) by adding a locales array:

// config/translatable.php
return [
    ...
    'locales' => [
        'en' => 'English',
        'de' => 'German',
        'fr' => 'French',
    ],
];

Alternatively you can "override" the config locales with the locales(...) method:

Translatable::make('Description')->locales([
    'en' => 'English',
    'de' => 'German',
]),

Single Line Option

By default the input field on the edit view is a textarea. If you want to change it to a single line input field you can add the singleLine() option:

Translatable::make('Description')->locales([...])->singleLine(),

Trix Editor

You can use the trix editor for your translated fields by using the trix() option:

Translatable::make('Description')->trix(),

Index View

By default the locale used when displaying the field on the index view is determined by app()->getLocale(). To override this you can use the indexLocale($locale) option:

Translatable::make('Description')->indexLocale('de'),
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].