PHPackages                             zpmlabs/i18n-engine-laravel - 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. zpmlabs/i18n-engine-laravel

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

zpmlabs/i18n-engine-laravel
===========================

Laravel package for i18n engine integration.

v1.0.0(2mo ago)04MITPHPPHP ^8.2

Since Feb 26Pushed 2mo agoCompare

[ Source](https://github.com/zpm-packages/i18n-engine-laravel)[ Packagist](https://packagist.org/packages/zpmlabs/i18n-engine-laravel)[ RSS](/packages/zpmlabs-i18n-engine-laravel/feed)WikiDiscussions main Synced 1mo ago

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

zpmlabs/i18n-engine-laravel
===========================

[](#zpmlabsi18n-engine-laravel)

Laravel i18n engine package for translation-table based querying.

Namespace
---------

[](#namespace)

`ZPMLabs\\I18nEngine`

Install
-------

[](#install)

```
composer require zpmlabs/i18n-engine-laravel
```

Model usage
-----------

[](#model-usage)

```
use ZPMLabs\I18nEngine\Contracts\HasTranslationTable;
use ZPMLabs\I18nEngine\Traits\InteractsWithTranslationTable;

class Article extends Model implements HasTranslationTable
{
	use InteractsWithTranslationTable;

	protected $table = 'articles';
	protected $fillable = ['title'];

	public function translatedColumns(): array
	{
		return ['title'];
	}
}
```

Query macros
------------

[](#query-macros)

- `withTranslations(?string $locale = null)`
- `withTranslationsList()`

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

[](#configuration)

Publish config:

```
php artisan vendor:publish --tag=i18n-engine-config
```

Config file: `config/i18n-engine.php`

```
return [
	'default_locale' => 'en',
	'query_param' => 'lang',
	'header' => 'Accept-Language',
	'normalize_locale' => true,
	'foreign_key' => 'foreign_id',
	'locale_key' => 'language',
	'table_suffix' => '_translations',
	'skip_locale_changes_for_routes' => [],
	'request_locale_handler' => \ZPMLabs\I18nEngine\Handlers\FilamentLocaleRequestHandler::class,
];
```

Key notes:

- `table_suffix`: suffix for translation tables (example: `articles_translations`).
- `foreign_key`: FK column in translation tables pointing to base model PK.
- `locale_key`: locale column in translation tables.
- `normalize_locale`: normalizes values like `sr-RS,sr;q=0.9` to `sr`.
- `request_locale_handler`: optional class implementing `LocaleRequestHandler` for custom request-specific locale resolution (Filament handler is default).

### Custom request locale handler

[](#custom-request-locale-handler)

If you want to fully control locale detection for specific requests, create your own handler:

```
namespace App\I18n;

use ZPMLabs\I18nEngine\Contracts\LocaleRequestHandler;

final class AdminLocaleHandler implements LocaleRequestHandler
{
	public function canHandle(object $request): bool
	{
		return method_exists($request, 'is') && $request->is('admin/*');
	}

	public function resolveLocale(object $request, string $queryParam, string $headerName): ?string
	{
		return (string) $request->query($queryParam, 'en');
	}
}
```

Then set it in config:

```
'request_locale_handler' => \App\I18n\AdminLocaleHandler::class,
```

The package calls `resolveLocale()` on the configured handler and uses the returned value as the locale candidate. Return `null` (or an empty value) from your handler when you want the default i18n-engine locale flow to continue.

Migration example
-----------------

[](#migration-example)

Generate migration command
--------------------------

[](#generate-migration-command)

Use the package command to generate a translation-table migration from an existing model table:

```
php artisan i18n-engine:make App\\Models\\Article
```

Common options:

- `--connection=`: inspect a specific DB connection
- `--path=database/migrations`: custom output path
- `--stub=database/stubs/create_translation_table.stub`: custom stub path
- `--module=`: write migration to `Modules//Database/Migrations`
- `--id-type=uuid|ulid|int`: force FK type
- `--all`: include all columns except meta/key columns

Examples:

```
php artisan i18n-engine:make App\\Models\\Article --connection=mysql
php artisan i18n-engine:make App\\Models\\Article --module=Blog
php artisan i18n-engine:make App\\Models\\Article --path=database/migrations/custom --id-type=uuid
```

The generated migration name pattern is:

- `YYYY_MM_DD_HHMMSS_create__translations_table.php`

The command reads package config keys (`i18n-engine.table_suffix`, `i18n-engine.foreign_key`, `i18n-engine.locale_key`) while generating output.

Example for base table `articles` and translated column `title`:

```
Schema::create('articles_translations', function (Blueprint $table) {
	$table->bigIncrements('translation_id');
	$table->unsignedBigInteger('foreign_id');
	$table->string('language', 8);

	$table->string('title')->nullable();

	$table->timestamps();

	$table->unique(['foreign_id', 'language']);
	$table->index('language');
});
```

This layout matches the package defaults (`foreign_id`, `language`, `_translations`).

Testing
-------

[](#testing)

```
composer test
```

Test logs are written to:

- `tests/logs/query-builder.log` (translation table snapshots + query results)
- `tests/logs/junit.xml` (JUnit report)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance86

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

75d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/211412089?v=4)[ZPM Labs](/maintainers/zpmlabs)[@ZPMLabs](https://github.com/ZPMLabs)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zpmlabs-i18n-engine-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/zpmlabs-i18n-engine-laravel/health.svg)](https://phpackages.com/packages/zpmlabs-i18n-engine-laravel)
```

###  Alternatives

[genealabs/laravel-model-caching

Automatic caching for Eloquent models.

2.4k4.8M26](/packages/genealabs-laravel-model-caching)[mikebronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k127.1k1](/packages/mikebronner-laravel-model-caching)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[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)[kerigard/laravel-lang-ru

Ru lang for Laravel

2116.8k](/packages/kerigard-laravel-lang-ru)

PHPackages © 2026

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