PHPackages                             quarasique/filament-translation-helper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. quarasique/filament-translation-helper

ActiveLibrary[Localization &amp; i18n](/categories/localization)

quarasique/filament-translation-helper
======================================

A Filament plugin that provides automatic translations with fallback support for resources, forms and tables

1.0.3(6mo ago)013MITPHPPHP ^8.2

Since Oct 24Pushed 6mo agoCompare

[ Source](https://github.com/Quarasique/filament-translation-helper)[ Packagist](https://packagist.org/packages/quarasique/filament-translation-helper)[ RSS](/packages/quarasique-filament-translation-helper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Filament Translation Helper
===========================

[](#filament-translation-helper)

A powerful Filament plugin that provides automatic translations with intelligent fallback support for resources, forms, tables, and navigation elements.

Features
--------

[](#features)

- 🔄 **Automatic Translation Discovery**: Automatically translates field labels, section headings, and column names
- 🎯 **Intelligent Fallback System**: Falls back to common field translations or generated labels when specific translations aren't found
- 🌐 **Multi-language Support**: Built-in support for multiple locales with easy language switching
- 📝 **BaseResource Class**: Extended Resource class with automatic label translation
- 🎨 **Language Switcher Component**: Ready-to-use language switcher widget for your admin panel
- ⚙️ **Configurable**: Easily configure available locales and default language
- 🚀 **Zero Configuration**: Works out of the box with sensible defaults

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require quarasique/filament-translation-helper
```

Publish the configuration and language files:

```
php artisan filament-translation-helper:publish
```

Or publish them separately:

```
# Publish configuration
php artisan vendor:publish --tag="filament-translation-helper-config"

# Publish language files
php artisan vendor:publish --tag="filament-translation-helper-lang"
```

Configuration
-------------

[](#configuration)

### Available Locales

[](#available-locales)

Configure available locales in `config/filament-translation-helper.php`:

```
return [
    'available_locales' => [
        'en' => 'English',
        'ru' => 'Русский',
        'es' => 'Español',
        'fr' => 'Français',
    ],

    'default_locale' => env('APP_LOCALE', 'en'),
];
```

### Middleware Setup

[](#middleware-setup)

Add the locale middleware to your Filament panel configuration:

```
use Quarasique\FilamentTranslationHelper\Http\Middleware\SetLocale;

public function panel(Panel $panel): Panel
{
    return $panel
        ->middleware([
            SetLocale::class,
            // ... other middleware
        ]);
}
```

Usage
-----

[](#usage)

### Using BaseResource

[](#using-baseresource)

Extend the BaseResource class instead of the default Filament Resource:

```
use Quarasique\FilamentTranslationHelper\Resources\BaseResource;

class UserResource extends BaseResource
{
    protected static ?string $model = User::class;

    // Labels are automatically translated from resources.user.label
    // and resources.user.plural_label
}
```

### 3. Use translateLabel() macro in forms and tables:

[](#3-use-translatelabel-macro-in-forms-and-tables)

```
// In your form schema
TextInput::make('name')
    ->translateLabel() // Uses resources.user.fields.name
    ->required(),

// In your table columns
TextColumn::make('email')
    ->translateLabel() // Uses resources.user.fields.email
    ->searchable(),
```

### 4. Create translation files:

[](#4-create-translation-files)

```
// lang/en/resources.php
return [
    'user' => [
        'label' => 'User',
        'plural_label' => 'Users',
        'fields' => [
            'name' => 'Name',
            'email' => 'Email Address',
            'created_at' => 'Created At',
        ],
    ],
];

// lang/ru/resources.php
return [
    'user' => [
        'label' => 'Пользователь',
        'plural_label' => 'Пользователи',
        'fields' => [
            'name' => 'Имя',
            'email' => 'Email адрес',
            'created_at' => 'Дата создания',
        ],
    ],
];
```

How It Works
------------

[](#how-it-works)

### Translation Strategy

[](#translation-strategy)

The plugin follows this lookup order for translations:

1. **Resource-specific**: `resources.{resource-key}.fields.{field-name}`
2. **Common fields**: `common.fields.{field-name}`
3. **Base field name**: `common.fields.{base-name}` (for fields like `user.name` → `name`)
4. **Automatic fallback**: Generated from field name (snake\_case → Title Case)

This means you can have translations for specific resources, common field translations that work across all resources, or rely on automatic label generation.

Examples
--------

[](#examples)

### Translation Examples

[](#translation-examples)

**With translation files**:

```
// lang/ru/common.php => 'fields' => ['first_name' => 'Имя']
TextInput::make('first_name') // → "Имя" (from translation)

// lang/en/common.php => 'fields' => ['first_name' => 'First Name']
TextInput::make('first_name') // → "First Name" (from translation)
```

**Without translation files** (automatic fallback):

```
TextInput::make('first_name') // → "First Name" (auto-generated)
TextInput::make('email_verified_at') // → "Email Verified At" (auto-generated)
Section::make('user_details') // → "User Details" (auto-generated)
```

### Form Example

[](#form-example)

```
public static function form(Form $form): Form
{
    return $form
        ->schema([
            TextInput::make('name'), // Translated or "Name" fallback
            TextInput::make('email'), // Translated or "Email" fallback
            TextInput::make('custom_field'), // Translated or "Custom Field" fallback
        ]);
}
```

### Table Example

[](#table-example)

```
public static function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('name'), // Auto-translated
            TextColumn::make('email'), // Auto-translated
            TextColumn::make('created_at'), // Auto-translated
        ]);
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Manual Translation Helper

[](#manual-translation-helper)

```
use Quarasique\FilamentTranslationHelper\Support\TranslationHelper;

// Get translation with fallback
$label = TranslationHelper::getWithFallback('resources.user.fields.full_name');
// Returns translation if exists, or "Full Name" as fallback
```

### Language Switcher Configuration

[](#language-switcher-configuration)

Add the language switcher widget to your Filament panel:

```
use Quarasique\FilamentTranslationHelper\Components\LanguageSwitcher;

public function panel(Panel $panel): Panel
{
    return $panel
        ->widgets([
            LanguageSwitcher::class,
        ]);
}
```

### Custom Resource Keys

[](#custom-resource-keys)

By default, resources use snake\_case of their class name. Override this:

```
class UserProfileResource extends BaseResource
{
    protected static function getResourceKey(): string
    {
        return 'user-profile'; // Uses resources.user-profile.*
    }
}
```

Commands
--------

[](#commands)

Generate resources with translation support:

```
php artisan filament-translation-helper:make-resource User
```

Publish translation templates:

```
php artisan filament-translation-helper:publish-translations
```

Configuration
-------------

[](#configuration-1)

The config file allows you to customize:

- Available locales
- Default and fallback locales
- Translation file structure
- Label formatting options

Translation File Structure
--------------------------

[](#translation-file-structure)

The plugin expects this structure in your language files:

```
// lang/{locale}/resources.php
return [
    'resource-key' => [
        'label' => 'Singular Label',
        'plural_label' => 'Plural Label',
        'fields' => [
            'field_name' => 'Field Label',
            // ...
        ],
        'actions' => [
            'action_name' => 'Action Label',
            // ...
        ],
    ],
];
```

Testing
-------

[](#testing)

Run the tests with:

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Quarasique](https://github.com/quarasique)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance66

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

200d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/071d23898fa36b244a144a083e7738b2b59b45e6c6c7fcd737fd8885d7d1bda4?d=identicon)[Quarasique](/maintainers/Quarasique)

---

Top Contributors

[![Quarasique](https://avatars.githubusercontent.com/u/26576363?v=4)](https://github.com/Quarasique "Quarasique (5 commits)")

---

Tags

pluginlaravellocalizationi18ntranslationsfilament

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/quarasique-filament-translation-helper/health.svg)

```
[![Health](https://phpackages.com/badges/quarasique-filament-translation-helper/health.svg)](https://phpackages.com/packages/quarasique-filament-translation-helper)
```

###  Alternatives

[outhebox/laravel-translations

Manage your Laravel translations with a beautiful UI. Add, edit, delete, import, and export translations with ease.

80687.6k](/packages/outhebox-laravel-translations)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

3812.2k](/packages/erag-laravel-lang-sync-inertia)[craft-forge/filament-language-switcher

Zero-config language switcher for Filament admin panels. Automatically scans available translations, renders dropdown with country flags, persists selection via sessions.

1016.4k](/packages/craft-forge-filament-language-switcher)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
