classic-o/nova-multilingual

This package is abandoned and no longer maintained. No replacement package was suggested.

Field for Laravel Nova that will let you ability to create a multilingual website.

This package has no released version yet, and little information is available.


README

Field for Laravel Nova that will let you ability to create a multilingual website.

Table of Contents

Features

When creating a message, the field creates duplicates for all languages. Then you can switch to the desired language of post and change the content.
After deleting one of the posts, all its duplicates will delete.

Requirements

Testing on

  • Laravel 7.*
  • Nova 3.*

Install

composer require classic-o/nova-multilingual

php artisan vendor:publish --provider="ClassicO\NovaMultilingual\FieldServiceProvider"

Configuration

See configuration file

For each table where you want to add multilingualism, add 2 string columns: lang_key and group_id (you can change column names in the configuration file)
After that add trait (ClassicO\NovaMultilingual\MultilingualTrait) to your resource.

Trait uses the following resource methods: __construct, indexQuery, newModel, redirectAfterCreate. If you also use these methods, repeat their implementation as in my trait.
Field groups posts using group_id column. If you want to change the group_id generation implementation, use static method in your resource:

public static function generateLanguageGroupId(): string

On the Index page you will see only posts of the installed language in the system

Usage

Add Field to the resource for switching between languages

use ClassicO\NovaMultilingual\Multilingual;

class Post extends Resource
{
    ...
     public function fields(Request $request)
        {
            return [
                ...
                Multilingual::make('Languages'),
                ...
            ];
        }
    ...
}

By default, on the index page, when you select the post language, you will be redirected to the Edit view. If you want to redirect to Details view, use the following method:

Multilingual::make('Languages')
    ->toDetails(),

After that, on the public website, you can search posts by language or single post by group_id + language

Screenshots

Multilingual