Translatable by Novius
CommunityPlugin to manage translatable models and fields.
Author:
Novius
Package health
Automated checks of this plugin's Composer package
15 checks
- Failed: GitHub Actions pinned to SHA — View details on Plumb
- Skipped: GitLab CI includes pinned to SHA
- Passed: Open security advisories
- Passed: Dependabot PR responsiveness — No open Dependabot PRs.
- Skipped: Renovate MR responsiveness
- Failed: Dependabot or Renovate configured — No dependency updater configuration found. View details on Plumb
- Skipped: Dependency update cooldown configured
- Failed: Provides a security policy — View details on Plumb
- Passed: Abandoned or archived — No consulted source marks the package abandoned (packagist, github).
- Passed: Commit and release recency — Active: last commit 75 days ago; last release 75 days ago.
-
Passed:
composer.lock not committed by library
—
composer.lockis absent from the released dist archive. - Warning: Dist archive is lean
-
Passed:
Current Laravel version supported
—
Package dependencies resolve together with current Laravel
13.0. -
Passed:
Current PHP version supported
—
Constraint
>=8.2supports current PHP8.5. - Skipped: Current Symfony version supported
filament/
namespace. Review the source and install at your own risk. Found
malware or an unresolved security issue the author won't
address?
Report it
.
Documentation
- Introduction
- Requirements
- Installation
- Assets
- Lang files
- Locale Filter
- Locale Column
- Locale Input
- Translations Column and features
- Lint
- Licence
#Introduction
This package allows you to manage Laravel Models that use Laravel Translatable in Laravel Filament.
#Requirements
- Laravel Filament >= 4
- Laravel >= 11.0
- PHP >= 8.2
#Installation
You can install the package via composer:
composer require novius/laravel-filament-translatable
#Assets
Next we need to publish the package's assets. We do this by running the following command:
php artisan vendor:publish --provider="Novius\LaravelFilamentTranslatable\LaravelFilamentTranslatableServiceProvider" --tag="public"
#Lang files
If you want to customize the lang files, you can publish them with:
php artisan vendor:publish --provider="Novius\LaravelFilamentTranslatable\LaravelFilamentTranslatableServiceProvider" --tag="lang"
#Locale Filter
Add the LocaleFilter filter on your Filament Resource.
use Filament\Resources\Resource;
use Novius\LaravelFilamentTranslatable\Filament\Tables\Filters\LocaleFilter;
class Post extends Resource
{
public static function table(Table $table): Table
{
return $table
/// ...
->filters([
LocaleFilter::make('locale'),
/// ...
]);
}
}
#Locale Column
Add the LocaleColumn column on your Filament Resource.
use Filament\Resources\Resource;
use Novius\LaravelFilamentTranslatable\Filament\Tables\Columns\LocaleColumn;
class Post extends Resource
{
public static function table(Table $table): Table
{
return $table
/// ...
->columns([
/// ...
LocaleColumn::make('locale'),
]);
}
}
#Locale Input
Add the Locale input on your Filament Resource.
use Filament\Resources\Resource;
use Novius\LaravelFilamentTranslatable\Filament\Forms\Components\Locale;
class Post extends Resource
{
public static function form(Form $form): Form
{
return $form
->schema([
// ...
Locale::make('locale')
->required(),
// ...
]);
}
}
#Translations Column and features
In your Filament Resource.
use Filament\Resources\Resource;
use Novius\LaravelFilamentTranslatable\Filament\Tables\Columns\TranslationsColumn;
class Post extends Resource
{
public static function form(Form $form): Form
{
return $form
->schema([
Hidden::make('locale_parent_id'),
]);
}
public static function form(Form $form): Form
{
return $table
// ...
->columns([
// ...
TranslationsColumn::make('translations')
->locales(['de', 'en']) // Optional. Restricted the locals displayed on this list
->flagWidth(16) // Optional. Width in pixel of the flags
->onlyMissing() // Optional. Will display only translations missing
->withoutMissing() // Optional. Will display only existing translations
,
// ...
]);
}
}
And declare your Create page like this :
<?php
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use LaravelLang\Locales\Facades\Locales;
use Novius\LaravelFilamentPageManager\Filament\PageManagerPlugin;
use Novius\LaravelFilamentTranslatable\Filament\Resources\Pages\CreateRecord;
class CreatePost extends CreateRecord
{
public static function getResource(): string
{
return PageManagerPlugin::getPlugin()->getResource('PostResource');
}
protected function getDataFromTranslate(Model $parent, string $locale): array
{
$data = $parent->attributesToArray();
// Modify data according the parent
$data['title'] = $parent->title.' '.Locales::get($locale)->native;
$data['slug'] = Str::slug($data['title']);
return $data;
}
}
#Lint
Lint your code with Laravel Pint using:
composer run-script lint
#Licence
This package is under GNU Affero General Public License v3 or (at your option) any later version.
The author
Novius is a French web agency specializing in the development of tailor-made web applications with Laravel.
We design robust, maintainable and business-oriented tools, with particular attention paid to the developer experience and the sustainability of projects. Our Filament plugins are used in production on customer projects and are designed to meet concrete needs, proven in the field.
From the same author
Action Preview
Action to preview a resource before saving or publishing it.
Author:
Novius
Slug
Plugin to generate and manage slugs automatically.
Author:
Novius
Relation Nested
Plugin to manage nested relationships using the Nested Set model.
Author:
Novius
Page Manager
Plugin to manage pages and structured content from the admin panel.
Author:
Novius
Featured Plugins
A selection of plugins curated by the Filament team
Sharp Theme
A theme that gives panels a precise, technical look with square corners, strong borders, and clear contrast.
Filament
Compact Theme
A theme that makes data-heavy panels easier to scan by fitting more useful information on each screen.
Filament
Spotlight Pro
Browse your Filament Panel with ease. Filament Spotlight Pro adds a Spotlight like Command Palette to your Filament Panel.
Dennis Koch