PHPackages                             berthott/laravel-translatable - 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. berthott/laravel-translatable

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

berthott/laravel-translatable
=============================

Laravel Helper for Model Translations

3.0.5(1y ago)07141MITPHP

Since Sep 16Pushed 1y ago2 watchersCompare

[ Source](https://github.com/berthott/laravel-translatable)[ Packagist](https://packagist.org/packages/berthott/laravel-translatable)[ RSS](/packages/berthott-laravel-translatable/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (6)Versions (12)Used By (1)

[![test workflow](https://github.com/berthott/laravel-translatable/actions/workflows/test.yml/badge.svg)](https://github.com/berthott/laravel-translatable/actions/workflows/test.yml/badge.svg)

Laravel-Translatable
====================

[](#laravel-translatable)

A helper for Model Translations in Laravel.

Easily add translatable fields to any of your eloquent models.

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

[](#installation)

```
$ composer require berthott/laravel-translatable
```

Usage / How it works
--------------------

[](#usage--how-it-works)

- Create your table and corresponding model, eg. with `php artisan make:model YourModel -m`
- Use the `translatable` macro to add translatable fields in your migration. Eg. ```
        Schema::create('dummies', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->translatable('user_input');
            $table->timestamps();
        });
    ```
- Add the `Translatable` trait to your newly generated model.
- Add a `translatableFields()` method to return an array with a list of your translatable fields to your model.
- Use `self::translatableRules` to gather all the rules you need to assure the correct data format, eg. ```
    {
        "en": "English String",
        "de": "German String",
    }
    ```
- If some fields should have optional languages, not listed in the packages config, you can add an `translatableOptionalFields()` method to return an array with the fields as keys and the optional languages as an value as an array.
- That's it. The package will take care of everything else.
    - There will be three tables migrated: `translatable_content`, `translatable_translations` and `translatable_languages`. The languages table will be filled according to the packages config.
    - A Laravel Model Observer will be registered for your model, that will hook into the data storing of your translatable fields.
    - An attribute holding the translated data will be added to your model automatically.

Options
-------

[](#options)

To change the default options use

```
$ php artisan vendor:publish --provider="berthott\Translatable\TranslatableServiceProvider" --tag="config"
```

- Inherited from [laravel-targetable](https://docs.syspons-dev.com/laravel-targetable)
    - `namespace`: String or array with one ore multiple namespaces that should be monitored for the configured trait. Defaults to `App\Models`.
    - `namespace_mode`: Defines the search mode for the namespaces. `ClassFinder::STANDARD_MODE` will only find the exact matching namespace, `ClassFinder::RECURSIVE_MODE` will find all subnamespaces. Defaults to `ClassFinder::STANDARD_MODE`.
- Language options
- `languages`: Defines the languages used in your application. Defaults to `['en' => 'English']`
- `optional_languages`: Defines the languages that should be treated optional. Defaults to `[]`
- `default_language`: Defines the language that should be used as default. Defaults to `en`

Compatibility
-------------

[](#compatibility)

Tested with Laravel 10.x.

License
-------

[](#license)

See [License File](license.md). Copyright © 2023 Jan Bladt.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

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 ~79 days

Recently: every ~94 days

Total

11

Last Release

582d ago

Major Versions

2.0.4 → 3.0.02023-02-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3034025?v=4)[Jan Bladt](/maintainers/berthott)[@berthott](https://github.com/berthott)

---

Top Contributors

[![berthott](https://avatars.githubusercontent.com/u/3034025?v=4)](https://github.com/berthott "berthott (22 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/berthott-laravel-translatable/health.svg)

```
[![Health](https://phpackages.com/badges/berthott-laravel-translatable/health.svg)](https://phpackages.com/packages/berthott-laravel-translatable)
```

###  Alternatives

[yorcreative/laravel-scrubber

A laravel package that scrubs sensitive information for you.

15776.6k2](/packages/yorcreative-laravel-scrubber)[php-translation/translator

Translator services

25224.8k5](/packages/php-translation-translator)[yakovenko/laravel-lighthouse-graphql-multi-schema

A Laravel package that provides multi-schema support for Lighthouse GraphQL.

17112.5k](/packages/yakovenko-laravel-lighthouse-graphql-multi-schema)[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1926.6k1](/packages/smmoosavi-php-gettext)

PHPackages © 2026

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