PHPackages                             eg-mohamed/laravel-missing-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. eg-mohamed/laravel-missing-translations

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

eg-mohamed/laravel-missing-translations
=======================================

Scan Laravel project files and append missing translation keys to JSON locale files

2.3.2(2w ago)543↓25%1MITPHPPHP ^8.3CI passing

Since Mar 18Pushed 2w agoCompare

[ Source](https://github.com/EG-Mohamed/laravel-missing-translations)[ Packagist](https://packagist.org/packages/eg-mohamed/laravel-missing-translations)[ Docs](https://github.com/eg-mohamed/laravel-missing-translations)[ GitHub Sponsors]()[ RSS](/packages/eg-mohamed-laravel-missing-translations/feed)WikiDiscussions main Synced 1w ago

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

[![bannar.svg](assets/bannar.svg)](assets/bannar.svg)[![Latest Version on Packagist](https://camo.githubusercontent.com/18266e0ee5ae94b052f717ab06c5a1774b8e3544c3225f42c62c8420e952c69c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f65672d6d6f68616d65642f6c61726176656c2d6d697373696e672d7472616e736c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eg-mohamed/laravel-missing-translations)[![Total Downloads](https://camo.githubusercontent.com/9b24782df7c2b3b2a9d09685f9d0adc0cb9b984697a05fbd88ff7299f6fd81e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f65672d6d6f68616d65642f6c61726176656c2d6d697373696e672d7472616e736c6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/eg-mohamed/laravel-missing-translations)

A Laravel dev-tool that scans your project for translation function calls and appends any missing keys to your JSON locale files. No more manually hunting for untranslated strings.

Supported Laravel versions: 11, 12, and 13.

Supports `__()`, `trans()`, `trans_choice()`, `@lang()`, `@choice()`, `Lang::get/has/choice()`, and Filament fields, columns, entries, and actions.

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

[](#installation)

Install as a dev dependency:

```
composer require eg-mohamed/laravel-missing-translations --dev
```

Publish the config file:

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

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

[](#configuration)

```
// config/laravel-missing-translations.php

return [
    // Directories to scan
    'paths' => [app_path(), resource_path('views')],

    // File extensions to include
    'extensions' => ['php', 'blade.php'],

    // Directories to exclude from scanning
    'exclude_paths' => [],

    // Sort keys alphabetically in the JSON output
    'sort_keys' => true,

    // Skip dotted keys like 'auth.failed' (PHP array-based translations)
    'exclude_dot_keys' => false,

    // Translation functions to detect
    'include_functions' => ['__', 'trans', 'trans_choice', '@lang', '@choice', 'Lang::get', 'Lang::has', 'Lang::choice'],

    // Regex patterns for keys to skip
    'exclude_patterns' => [],

    // Ignore package-namespaced keys like 'filament-shield::resource.role' (anything containing '::')
    'ignore_package_keys' => true,

    // Flags passed to json_encode when writing locale files
    'json_flags' => JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE,

    // Filament field, column, entry, and action scanning
    'filament' => [
        'enabled' => true,

        // Instance methods whose first string literal argument is user-facing text
        'methods' => [
            'label', 'placeholder', 'helperText', 'hint', 'hintTooltip',
            'description', 'heading', 'subheading', 'title',
            'modalHeading', 'modalDescription', 'modalSubmitActionLabel', 'modalCancelActionLabel',
            'emptyStateHeading', 'emptyStateDescription', 'tooltip',
            'prefix', 'suffix', 'navigationLabel', 'navigationGroup',
            'pluralLabel', 'singularLabel', 'breadcrumb',
        ],

        // Component classes whose ::make('Label') first argument is a display label
        // Field-name-style strings like ::make('email') are automatically excluded
        'static_methods' => ['Tab', 'Section', 'Fieldset', 'Group', 'Step'],
    ],
];
```

Usage
-----

[](#usage)

### Scan and write missing keys

[](#scan-and-write-missing-keys)

```
php artisan missing-translations en
```

This scans your project, compares found keys against `lang/en.json`, and appends any missing ones with an empty string value.

If no locale argument is provided and `--all` is not used, the command falls back to `config('app.locale')` automatically:

```
php artisan missing-translations
```

### Preview without writing

[](#preview-without-writing)

```
php artisan missing-translations en --dry-run
```

Displays a table of missing keys without modifying any files. Also shows summary statistics:

```
Keys scanned: 42 | Existing: 38 | Missing: 4
Dry run mode: no changes written.

```

### Process all existing locale files at once

[](#process-all-existing-locale-files-at-once)

```
php artisan missing-translations --all
```

Runs the scan against every `lang/*.json` file found in your project. If no JSON files exist, a helpful message is shown instead of a generic error.

### Remove unused keys

[](#remove-unused-keys)

```
php artisan missing-translations en --remove-unused
```

Finds keys that exist in `lang/en.json` but are no longer referenced in any scanned file, displays them, and removes them. Combine with `--dry-run` to preview without making changes:

```
php artisan missing-translations en --remove-unused --dry-run
```

### JSON output for CI pipelines

[](#json-output-for-ci-pipelines)

```
php artisan missing-translations en --json
```

Outputs results as JSON to stdout instead of the table format. Useful for CI pipelines — e.g. fail a build if missing translations count &gt; 0:

```
{
    "locale": "en",
    "existing_count": 38,
    "missing_count": 4,
    "missing_keys": [
        "New Key One",
        "New Key Two"
    ]
}
```

With `--remove-unused`:

```
{
    "locale": "en",
    "existing_count": 38,
    "missing_count": 4,
    "missing_keys": ["New Key One"],
    "unused_count": 2,
    "unused_keys": ["Old Key", "Stale Key"]
}
```

Filament Support
----------------

[](#filament-support)

When `filament.enabled` is `true`, the scanner also detects plain string literals passed directly to Filament component methods — no `__()` wrapper required.

**Fields, columns, entries, and actions are all covered:**

```
TextInput::make('email')
    ->label('Email Address')           // detected
    ->placeholder('Enter your email')  // detected
    ->helperText('Never shared');      // detected

TextColumn::make('status')
    ->label('Current Status')          // detected
    ->tooltip('Last updated today');   // detected

Action::make('approve')
    ->label('Approve')                 // detected
    ->modalHeading('Confirm Approval') // detected
    ->modalSubmitActionLabel('Yes, approve'); // detected
```

**Structural components** like `Section`, `Tab`, `Fieldset`, `Group`, and `Step` are scanned when their `::make()` argument looks like a display label (contains a space or starts with an uppercase letter):

```
Section::make('Personal Information') // detected — looks like a label
Tab::make('Account Settings')         // detected
TextInput::make('email')              // NOT detected — looks like a field name
```

**Auto-generated labels are captured too.** When a Filament field, column, or entry has no explicit `->label()`, Filament generates a label from the field name (e.g. `scheduled_time` → `Scheduled time`, `amount` → `Amount`). The scanner picks these up automatically:

```
TextColumn::make('scheduled_time')->time()->sortable(),
// captured as: "Scheduled time"

TextColumn::make('amount')->numeric()->sortable(),
// captured as: "Amount"

TextInput::make('firstName'),
// captured as: "First name"
```

The auto-label pass is skipped whenever the chain contains `->label(...)` or `->translateLabel(...)`.

Relationship dot-notation is handled the same way Filament does it:

- **Columns** use the second-to-last segment: `charityCase.title` → `Charity case`, `user.profile.name` → `Profile`
- **Fields and entries** use the last segment: `user.name` → `Name`

**Keys wrapped in `__()` are never double-counted.** If you write `->label(__('Email Address'))`, the key is captured by the standard `__()` scanner only.

**Extend the method list** in config to add any custom Filament methods or third-party component methods:

```
'filament' => [
    'methods' => [
        ...
        'columnLabel',
        'groupLabel',
    ],
],
```

How it works
------------

[](#how-it-works)

1. Uses Symfony Finder to crawl configured `paths` for files matching configured `extensions`
2. Extracts translation keys via regex from all supported function calls
3. When Filament scanning is enabled, also extracts plain string literals from label-like methods and structural component names
4. Diffs found keys against the existing locale JSON file
5. Appends missing keys with an empty string value, leaving existing translations untouched
6. Re-running the command is safe — no duplicates are ever added
7. File writes use `LOCK_EX` to prevent corruption from concurrent runs

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)

- [Mohamed Said](https://github.com/EG-Mohamed)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance96

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.7% 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 ~6 days

Total

12

Last Release

17d ago

Major Versions

1.2.0 → 2.0.02026-03-31

PHP version history (2 changes)1.0.0PHP ^8.4

2.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23424932?v=4)[Mohamed Said](/maintainers/EG-Mohamed)[@EG-Mohamed](https://github.com/EG-Mohamed)

---

Top Contributors

[![EG-Mohamed](https://avatars.githubusercontent.com/u/23424932?v=4)](https://github.com/EG-Mohamed "EG-Mohamed (18 commits)")[![Max13](https://avatars.githubusercontent.com/u/531249?v=4)](https://github.com/Max13 "Max13 (1 commits)")

---

Tags

laravelMohamed Saidlaravel-missing-translations

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/eg-mohamed-laravel-missing-translations/health.svg)

```
[![Health](https://phpackages.com/badges/eg-mohamed-laravel-missing-translations/health.svg)](https://phpackages.com/packages/eg-mohamed-laravel-missing-translations)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M41](/packages/spatie-laravel-pdf)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[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.

594266.8k1](/packages/askdkc-breezejp)[spatie/laravel-passkeys

Use passkeys in your Laravel app

463755.5k32](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[elegantly/laravel-translator

All on one translations management for Laravel

6326.3k](/packages/elegantly-laravel-translator)

PHPackages © 2026

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