PHPackages                             gertjanroke/translations - 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. gertjanroke/translations

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

gertjanroke/translations
========================

Translations: Easy way to make your database multilanguage

1.0.0(9y ago)024PHPPHP &gt;=5.6.4

Since Sep 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/GertjanRoke/Translations)[ Packagist](https://packagist.org/packages/gertjanroke/translations)[ Docs](https://github.com/GertjanRoke/Translations)[ RSS](/packages/gertjanroke-translations/feed)WikiDiscussions master Synced today

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

Translations
============

[](#translations)

Easy way to make your database multilanguage

Install
-------

[](#install)

```
composer require gertjanroke/translations
```

After install
-------------

[](#after-install)

### Publish files

[](#publish-files)

If all your models are directly in your app folder and your using the laravel convention, you do not need to publish the config file. But if your somehow not following this convention, like putting your models in a own folder. Than you need to publish the config file and define where your translation models are stored.

If you need to publish the config file, than first do the following think before running the publish command.

Add the following line to `config/app.php`.

at `providers`:

```
'providers' => [
	...
	Gertjanroke\Notification\NotificationServiceProvider::class,
	...
],
```

To publish the config file run the following command:

```
php artisan vendor:publish --provider="Gertjanroke\Notification\NotificationServiceProvider"
```

Usage
-----

[](#usage)

Now comes the fun part:

To use the translations trait you only need to add a `use` inside your model class. You can do so by:

```
class Page extends Model
{
	...
	use Translations;
	...
}
```

and add the `use` above your class like so:

```
...
use Gertjanroke\Translations\Traits\Translations;

class Page extends Model
{
	...
```

Now your almost done.

The only thing you need to do is make a translation model for the model you just added the trait.

Something like:

```
class PageTranslations extends Model
{
    //
}
```

The important part is that out of the box this package uses a model name like the one above. If you want to override this just edit the config file and your good to go.

Saving your translations
------------------------

[](#saving-your-translations)

The first thing you need to do is check with way works best for you. This package comes with a default request attribute on with he he build a foreach to save all values per locale. This format is as following:

```

```

If your do not like the key word `trans` you can easly change this in the config. To something like:

```

```

or

```

```

or what ever you like.

After you made your forms you now need to save the data. This package comes with two ways to do so. Just call the following function from your model and send the request object with it. like so:

```
public function store(Request $request)
{
	...
	$page = new Page();
	$page->saveTranslations($request);
	...
}
```

or the short version:

```
public function store(Request $request)
{
	...
	$page = new Page();
	$page->saveTrans($request);
	...
}
```

And the package will create a new row in your database table or it will update its existing row.

Magic funtions
--------------

[](#magic-funtions)

This package als comes with two handy funtions that let you do things like:

```
$page->title
```

and it will check if that attribute existing in your translations table. If it exists, the value will be returned in the currunt locale of your application.

The other magic function is dynamic getters. Let take the example from above and use that as a method.

```
$page->getTitle();
```

This will get the title just like the funtion above, but now you can specify with locale version you want of the given attribute.

```
$page->getTitle('en');
```

You can change `'en'` for the require locale.

Custom Foreign key
------------------

[](#custom-foreign-key)

If for some reason you do not like the way laravel handles the foreign keys and you want to use your own conventions, Thust do so by setting the `transForeignKey` variable in your main model. For example:

```
...
use Gertjanroke\Translations\Traits\Translations;

class Page extends Model
{
	...
	use Translations;

    protected $transForeignKey = 'pages_id';
    ...
}
```

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

2

Last Release

3555d ago

Major Versions

0.0.1 → 1.0.02016-10-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/8ab268dd9dc85846a497980d67527038e64f692e579fdad486c79a9ecad5ce93?d=identicon)[GertjanRoke](/maintainers/GertjanRoke)

---

Tags

translations

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gertjanroke-translations/health.svg)

```
[![Health](https://phpackages.com/badges/gertjanroke-translations/health.svg)](https://phpackages.com/packages/gertjanroke-translations)
```

###  Alternatives

[barryvdh/laravel-translation-manager

Manage Laravel Translations

1.7k3.7M18](/packages/barryvdh-laravel-translation-manager)[gettext/languages

gettext languages with plural rules

7532.0M12](/packages/gettext-languages)[kkomelin/laravel-translatable-string-exporter

Translatable String Exporter for Laravel

3281.5M17](/packages/kkomelin-laravel-translatable-string-exporter)[punic/punic

PHP-Unicode CLDR

1543.0M30](/packages/punic-punic)[outhebox/laravel-translations

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

81396.3k](/packages/outhebox-laravel-translations)[outl1ne/nova-translations-loader

This Laravel Nova package helps developers load translations into their packages.

395.7M46](/packages/outl1ne-nova-translations-loader)

PHPackages © 2026

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