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

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

subham/auto-translations
========================

Automatically generate translation files for all your Laravel models

v1.1.0(7mo ago)015[3 PRs](https://github.com/subhamsharmaa/auto-translations/pulls)MITPHPPHP ^8.1|^8.2|^8.3|^8.4CI passing

Since Oct 13Pushed 1mo agoCompare

[ Source](https://github.com/subhamsharmaa/auto-translations)[ Packagist](https://packagist.org/packages/subham/auto-translations)[ Docs](https://github.com/subhamsharmaa/auto-translations)[ GitHub Sponsors](https://github.com/subham)[ RSS](/packages/subham-auto-translations/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Auto Translation
========================

[](#laravel-auto-translation)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6bd24f8aab32eec947cc1717684eb30a4a933df43964432b03f78da4d806c3b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73756268616d2f6175746f2d7472616e736c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/subham/auto-translations)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a4afab58c0837bacd91610637357abf0ff53ba7531f6458b3db97c7d254c2885/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73756268616d736861726d61612f6175746f2d7472616e736c6174696f6e732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/subhamsharmaa/auto-translations/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/84ddcf5e9341471fc194ac47e0448213ce4b1ce71417acc76c0b2c910fe0c9fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73756268616d2f6175746f2d7472616e736c6174696f6e732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/subhamsharmaa/auto-translations/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8c86de296e8d76941496f63780afe2a609ffd65d481430cdf591f6a8b3ab7aed/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73756268616d2f6175746f2d7472616e736c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/subham/auto-translations)

Automatically generate translation files for all your Laravel models. This package scans your models and creates JSON translation files based on their fillable attributes.

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

[](#installation)

You can install the package via composer:

```
composer require subham/auto-translations
```

You can publish the config file with:

```
php artisan vendor:publish --tag="auto-translations-config"
```

This is the contents of the published config file:

```
    // Prefix for translation keys
    'prefix' => 'fields',

    // Suffix for translation keys
    'suffix' => 'label',

    // Locales to generate translations for
    'locale' => ['en', 'es', 'fr'],

    // Paths to scan for models
    'model_paths' => [
        app_path('Models'),
        // base_path('Modules/MyModule/Models'), // For modular apps
    ],

    // Where to publish translation files
    'publish_path' => resource_path('lang'),
];

```

Define Translation keys
-----------------------

[](#define-translation-keys)

1. Fillable fields from your model class.
2. Define translationKeys() method on your model class

```
class Product extends Model
{
    protected $fillable = ['name', 'price'];

    public function translationKeys(): array
    {
        return ['sku', 'category_name'];
    }
}

```

Translation Key Format
----------------------

[](#translation-key-format)

`{prefix}.{table_name}.{column_name}.{suffix}`

Example
-------

[](#example)

PrefixModelColumnSuffixFinal ResultUseremailusers.emailfieldsUseremailfields.users.emailfieldsUseremailcolumnfields.users.email.columnUsage
-----

[](#usage)

**Basic Command**

Generate translation files for all models:

```
php artisan auto-translations:generate

```

This will prompt you for confirmation if translation files already exist.

**Force Overwrite**

Overwrite existing translation files without confirmation:

```
php artisan auto-translations:generate --force

```

**Append Mode**

Add new translations while preserving existing ones:

```
php artisan auto-translations:generate --append

```

Use this when translators have customized translations and you want to add new keys only.

Example Output
--------------

[](#example-output)

For a **User** model with fillable attributes **\['name', 'email', 'phone'\]** with prefix **fields** and suffix **label**:

**Generated Translation File**

```
{
  "fields.users.email.label": "Email",
  "fields.users.name.label": "Name",
  "fields.users.phone.label": "Phone"
}

```

Important
---------

[](#important)

All generated translations will be based on model's fillable attributes. The package only creates the file structure and keys - you need to manually translate the values for each locale afterward.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Subham Sharma](https://github.com/subhamsharmaa)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance79

Regular maintenance activity

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87% 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 ~2 days

Total

2

Last Release

214d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d7e748c8040eaea80037de84fdf6bfb16fde753eb81cf08ba85d1b42c58515d?d=identicon)[ssuvam-dev](/maintainers/ssuvam-dev)

---

Top Contributors

[![subhamsharmaa](https://avatars.githubusercontent.com/u/86038239?v=4)](https://github.com/subhamsharmaa "subhamsharmaa (20 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelsubhamauto-translations

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[askdkc/breezejp

Laravel Starter Kit (Livewire+Breeze+Laravel UI+Jetstream)や標準のバリデーションメッセージを全て一瞬で日本語化し、言語切替機能も提供するパッケージです / This package provides all-in-one Japanese translation for Laravel StarterKit (Livewire StarterKit, Breeze, Laravel UI and Jetstream) packages and validation messages with language switching feature.

590244.8k1](/packages/askdkc-breezejp)[statikbe/laravel-filament-chained-translation-manager

A translation manager tool for Laravel Filament, that makes use of the Laravel Chained Translator.

92108.7k](/packages/statikbe-laravel-filament-chained-translation-manager)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[elegantly/laravel-translator

All on one translations management for Laravel

6216.9k](/packages/elegantly-laravel-translator)[andrewdwallo/transmatic

Automate and streamline real-time text translations in your Laravel applications

5511.6k](/packages/andrewdwallo-transmatic)[smousss/laravel-globalize

Make Laravel projects translatable in a matter of seconds!

2266.3k](/packages/smousss-laravel-globalize)

PHPackages © 2026

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