PHPackages                             aw-studio/laravel-deeplable - 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. [API Development](/categories/api)
4. /
5. aw-studio/laravel-deeplable

ActiveLibrary[API Development](/categories/api)

aw-studio/laravel-deeplable
===========================

v0.9.5(1y ago)62.6k31MITPHPPHP ^8.0|^8.1|^8.2

Since Aug 4Pushed 1y ago3 watchersCompare

[ Source](https://github.com/aw-studio/laravel-deeplable)[ Packagist](https://packagist.org/packages/aw-studio/laravel-deeplable)[ RSS](/packages/aw-studio-laravel-deeplable/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (9)Versions (18)Used By (1)

Laravel Deeplable
=================

[](#laravel-deeplable)

A package for translating Laravel Models using DeepL's API. It contains a translator for the [astrotomic/laravel-translatable](https://github.com/Astrotomic/laravel-translatable) composer package. Translators for other usecases can be written easily.

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

[](#installation)

Install the package via composer:

```
composer require aw-studio/laravel-deeplable
```

and publish the config file:

```
php artisan vendor:publish --tag=deeplable --force
```

Setup
-----

[](#setup)

After publishing the `config/deeplable.php` you must enter your DeepL-Secret in order to use their API. You may also configure all Models you want to translate when you run the `deeplable:run` command.

Usage
-----

[](#usage)

You can translate your translatable models to all languages that are set in your `config/translatable.php` as long as they are available on DeepL. In order to translate your models to a target language the default translation (`fallback_locale`) must be available. You can use the `Deeplable` trait to easily translate your model to a target language.

```
use AwStudio\Deeplable\Traits\Deeplable;

class Post extends Model
{
    use Deeplable;
}
```

Imagine you have stored the default language ('en') and want to auto-generate the german translation for all translated attributes:

```
$post = Post::first();

$post->translateTo('de');
$post->translateAttributeTo('de', 'title');
$post->translateAttributesTo('de', ['title', 'text']);
```

If you want to translate all Models to all locales, simply run the `deeplable` artisan command:

```
php artisan deeplable:run
```

You may also set an argument if you want to translate a specific language:

```
php artisan deeplable:run fr
```

### Translators

[](#translators)

Translators have the purpose to bind a translatable attribute to a model. A build in example is the `AstrotomicTranslator` that updates models that are translated by the [astrotomic/laravel-translatable](https://github.com/Astrotomic/laravel-translatable) package.

#### Creating A Translator

[](#creating-a-translator)

A translator must extend the `AwStudio\Deeplable\Translators\BaseTranslator` class which has 2 abstract methods:

```
class AstrotomicTranslator
{
    protected function translateAttribute(Model $model, $attribute, $locale, $translation)
    {
        $model->translateOrNew($locale)->setAttribute($attribute, $translation);
    }

    public function getTranslatedAttributes(Model $model, $locale)
    {
        return array_keys($model->getTranslationsArray()[$locale] ?? []);
    }
}
```

#### Registering The Translator

[](#registering-the-translator)

A translator may be registered in a Service Provider like this:

```
use AwStudio\Deeplable\Translators\Resolver;
use Astrotomic\Translatable\Contracts\Translatable;

public function register()
{
    Translator::register(Translatable::class, function () {
            return new AstrotomicTranslator($this->app['deeplable.api']);
    });
}
```

#### Using The Translator

[](#using-the-translator)

The translator can then be used like this:

```
use AwStudio\Deeplable\Facades\Translator;
use Astrotomic\Translatable\Contracts\Translatable;

Translator::get(Translatable::class)->translate($post, 'de', 'en'); // Translates the whole model from en to de
Translator::get(Translatable::class)->translateAttributes($post, ['title', 'text'], 'de', 'en'); // Translates attributes title and text from en to de
```

### Translation Strategy

[](#translation-strategy)

Given the case that different models need different translators, a translation strategy can be specified in a service provider like this:

```
use AwStudio\Deeplable\Facades\Translator;
use AwStudio\Deeplable\Translators\Resolver;
use Astrotomic\Translatable\Contracts\Translatable;

public function register()
{
    Translator::strategy(function(Model $model) {
        if($model instanceof Translatable) {
            return Translatable::class;
        }
        // something else...
    });
}
```

The correct translator can now be received like this:

```
Translator::for($post)->translate(...);
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance48

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~143 days

Total

14

Last Release

384d ago

PHP version history (2 changes)v0.1PHP ^8.0

v0.9.4PHP ^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b2d65d58480dd7fdbf4f4593158cbd0634550ee9210c49957cc48c8a8ccaef6?d=identicon)[jannescb](/maintainers/jannescb)

---

Top Contributors

[![jannescb](https://avatars.githubusercontent.com/u/17292622?v=4)](https://github.com/jannescb "jannescb (20 commits)")[![cbl](https://avatars.githubusercontent.com/u/29352871?v=4)](https://github.com/cbl "cbl (16 commits)")[![lpheller](https://avatars.githubusercontent.com/u/36259611?v=4)](https://github.com/lpheller "lpheller (6 commits)")[![larshanskrause](https://avatars.githubusercontent.com/u/35800965?v=4)](https://github.com/larshanskrause "larshanskrause (5 commits)")

---

Tags

apideepllaraveltranslation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aw-studio-laravel-deeplable/health.svg)

```
[![Health](https://phpackages.com/badges/aw-studio-laravel-deeplable/health.svg)](https://phpackages.com/packages/aw-studio-laravel-deeplable)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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