PHPackages                             aon4o/laravel-translation-loader - 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. [Database &amp; ORM](/categories/database)
4. /
5. aon4o/laravel-translation-loader

ActiveLibrary[Database &amp; ORM](/categories/database)

aon4o/laravel-translation-loader
================================

Store your language lines in the database, yaml or other sources

v4.0.0(9mo ago)1759MITPHPPHP ^8.0CI passing

Since Dec 13Pushed 9mo agoCompare

[ Source](https://github.com/aon4o/laravel-translation-loader)[ Packagist](https://packagist.org/packages/aon4o/laravel-translation-loader)[ Docs](https://github.com/aon4o/laravel-translation-loader)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/aon4o-laravel-translation-loader/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (6)Versions (4)Used By (0)

Store your language lines in the database
=========================================

[](#store-your-language-lines-in-the-database)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9214f485d579847b5c05999fd395123f6bc89ad33949195012f27c77581c63e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616f6e346f2f6c61726176656c2d7472616e736c6174696f6e2d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aon4o/laravel-translation-loader)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![GitHub Workflow Status](https://camo.githubusercontent.com/84e5f22dc7693f305466d4a0e83d8eb88b9209ccdf1a22d2b4969a7454ca4a75/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616f6e346f2f6c61726176656c2d7472616e736c6174696f6e2d6c6f616465722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/84e5f22dc7693f305466d4a0e83d8eb88b9209ccdf1a22d2b4969a7454ca4a75/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616f6e346f2f6c61726176656c2d7472616e736c6174696f6e2d6c6f616465722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473267374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/854b655ee2e9587889d8804588738ed6017e962b436308ef50ccea80ea795365/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616f6e346f2f6c61726176656c2d7472616e736c6174696f6e2d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/aon4o/laravel-translation-loader)

Disclaimer
----------

[](#disclaimer)

This is NOT an official package provided by Spatie. This is a fork of the original package with some minor changes:

- Added support for Namespaced translations. [\#178](https://github.com/spatie/laravel-translation-loader/pull/178)

Base Usage
----------

[](#base-usage)

In a vanilla Laravel or Lumen installation, you can use [language files](https://laravel.com/docs/localization) to localize your app. This package will enable the translations to be stored in the database. You can still use all the features of [the `__` helper function](https://laravel.com/docs/localization#retrieving-translation-strings) you know and love.

```
__('messages.welcome', ['name' => 'dayle']);
// or
__('clients::messages.welcome', ['name' => 'dayle']);
```

You can even mix using language files and the database. If a translation is present in both a file and the database, the database version will be returned.

Want to use a different source for your translations? No problem! The package is [easily extendable](https://github.com/spatie/laravel-translation-loader#creating-your-own-translation-providers).

Spatie is a web design agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Support Spatie
--------------

[](#support-spatie)

[![](https://camo.githubusercontent.com/d4a710fef761fd7be0e0460a243b2c217e7e182457c50025937ad0b9186fc974/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d7472616e736c6174696f6e2d6c6f616465722e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-translation-loader)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require aon4o/laravel-translation-loader
```

In `config/app.php` (Laravel) or `bootstrap/app.php` (Lumen) you should replace Laravel's translation service provider

```
Illuminate\Translation\TranslationServiceProvider::class,
```

by the one included in this package:

```
Spatie\TranslationLoader\TranslationServiceProvider::class,
```

You must publish and run the migrations to create the `language_lines` table:

```
php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="translation-loader-migrations"
php artisan migrate
```

Optionally, you could publish the config file using this command.

```
php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="translation-loader-config"
```

This is the contents of the published config file:

```
return [

    /*
     * The name of the table in which the language lines are stored.
     */
    'table_name' => 'language_lines',

    /*
     * Language lines will be fetched by these loaders. You can put any class here that implements
     * the Spatie\TranslationLoader\TranslationLoaders\TranslationLoader-interface.
     */
    'translation_loaders' => [
        Spatie\TranslationLoader\TranslationLoaders\Db::class,
    ],

    /*
     * This is the model used by the Db Translation loader. You can put any model here
     * that extends Spatie\TranslationLoader\LanguageLine.
     */
    'model' => Spatie\TranslationLoader\LanguageLine::class,

    /*
     * This is the translation manager which overrides the default Laravel `translation.loader`
     */
    'translation_manager' => Spatie\TranslationLoader\TranslationLoaderManager::class,

];
```

> **Note:** publishing assets doesn't work out of the box in Lumen. Instead, you have to copy the files from the repo.

Usage
-----

[](#usage)

You can create a translation in the database by creating and saving an instance of the `Spatie\TranslationLoader\LanguageLine`-model:

```
use Spatie\TranslationLoader\LanguageLine;

LanguageLine::create([
    'namespace' => '*',
    'group' => 'validation',
    'key' => 'required',
    'text' => ['en' => 'This is a required field', 'nl' => 'Dit is een verplicht veld'],
]);
```

You can fetch the translation with [Laravel's default `__` function](https://laravel.com/docs/localization#retrieving-translation-strings):

```
__('validation.required'); // returns 'This is a required field'

app()->setLocale('nl');

__('validation.required'); // returns 'Dit is een verplicht veld'
```

You can still keep using the default language files as well. If a requested translation is present in both the database and the language files, the database version will be returned.

If you need to store/override JSON translation lines, just create a normal LanguageLine with `group => '*'`.

Creating your own translation providers
---------------------------------------

[](#creating-your-own-translation-providers)

This package ships with a translation provider that can fetch translations from the database. If you're storing your translations in a yaml-file, a csv-file, etc., you can easily extend this package by creating your own translation provider.

A translation provider can be any class that implements the `Spatie\TranslationLoader\TranslationLoaders\TranslationLoader`-interface. It contains only one method:

```
namespace Spatie\TranslationLoader\TranslationLoaders;

interface TranslationLoader
{
    /*
     * Returns all translations for the given locale and group.
     */
    public function loadTranslations(string $locale, string $group, string|null $namespace = null): array;
}
```

Translation providers can be registered in the `translation_loaders` key of the config file.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Testing
-------

[](#testing)

```
composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you've found a bug regarding security, please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

36

—

LowBetter than 83% of packages

Maintenance56

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.2% 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 ~164 days

Total

2

Last Release

292d ago

Major Versions

v3.0.0 → v4.0.02025-06-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/927acab553d76e07d6d2e2081b7eb6bea657b9550901a036f647b6a7f5af5c66?d=identicon)[aon4o](/maintainers/aon4o)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (96 commits)")[![aon4o](https://avatars.githubusercontent.com/u/48474870?v=4)](https://github.com/aon4o "aon4o (30 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (17 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (3 commits)")[![skalero01](https://avatars.githubusercontent.com/u/2976641?v=4)](https://github.com/skalero01 "skalero01 (2 commits)")[![aginev](https://avatars.githubusercontent.com/u/8341783?v=4)](https://github.com/aginev "aginev (2 commits)")[![erikn69](https://avatars.githubusercontent.com/u/4933954?v=4)](https://github.com/erikn69 "erikn69 (2 commits)")[![bmichotte](https://avatars.githubusercontent.com/u/235510?v=4)](https://github.com/bmichotte "bmichotte (2 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (1 commits)")[![Rattone](https://avatars.githubusercontent.com/u/7362607?v=4)](https://github.com/Rattone "Rattone (1 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (1 commits)")[![selcukcukur](https://avatars.githubusercontent.com/u/5716652?v=4)](https://github.com/selcukcukur "selcukcukur (1 commits)")[![SimZal](https://avatars.githubusercontent.com/u/5641956?v=4)](https://github.com/SimZal "SimZal (1 commits)")[![spoyntersmith](https://avatars.githubusercontent.com/u/22387308?v=4)](https://github.com/spoyntersmith "spoyntersmith (1 commits)")[![uyab](https://avatars.githubusercontent.com/u/149716?v=4)](https://github.com/uyab "uyab (1 commits)")[![vmitchell85](https://avatars.githubusercontent.com/u/1248035?v=4)](https://github.com/vmitchell85 "vmitchell85 (1 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (1 commits)")

---

Tags

laravelpackagetranslationspatielaravellanguagetranslatedatabasei8ndblaravel-translation-loader

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/aon4o-laravel-translation-loader/health.svg)

```
[![Health](https://phpackages.com/badges/aon4o-laravel-translation-loader/health.svg)](https://phpackages.com/packages/aon4o-laravel-translation-loader)
```

###  Alternatives

[spatie/laravel-translation-loader

Store your language lines in the database, yaml or other sources

8342.8M43](/packages/spatie-laravel-translation-loader)[tomatophp/filament-translations

Manage your translation with DB and cache, you can scan your languages tags like trans(), \_\_(), and get the string inside and translate them use UI.

6228.4k3](/packages/tomatophp-filament-translations)[spatie/laravel-translatable

A trait to make an Eloquent model hold translations

2.4k22.1M345](/packages/spatie-laravel-translatable)[codezero/laravel-unique-translation

Check if a translated value in a JSON column is unique in the database.

186944.4k6](/packages/codezero-laravel-unique-translation)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

159150.0k](/packages/cybercog-laravel-clickhouse)[webparking/laravel-db-rebuild

A laravel package that allows for quick database rebuilds with presets.

448.8k](/packages/webparking-laravel-db-rebuild)

PHPackages © 2026

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