Skip to content

OthmanHaba/laravel-missing-translations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Missing Translations

Laravel Missing Translations

A fast CLI tool to find missing translation keys in your Laravel project. It scans your PHP and Blade files for translation function calls (__(), trans(), @lang()) and compares them against your language files.

Features

  • Scans __(), trans(), and @lang() function calls
  • Automatically excludes common directories (vendor, node_modules, etc.)
  • Custom directory exclusions
  • Multi-locale support
  • Cross-platform (Linux, macOS, Windows)

Installation

Download Pre-built Binary

Download the appropriate binary for your system from the Releases page:

Platform Architecture Binary
Linux x64 laravel-missing-translations-linux-amd64
Linux ARM64 laravel-missing-translations-linux-arm64
macOS Intel laravel-missing-translations-darwin-amd64
macOS Apple Silicon laravel-missing-translations-darwin-arm64
Windows x64 laravel-missing-translations-windows-amd64.exe
Windows ARM64 laravel-missing-translations-windows-arm64.exe

Linux/macOS

Direct download (recommended):

# macOS Apple Silicon
curl -LO https://github.com/OthmanHaba/laravel-missing-translations/releases/latest/download/laravel-missing-translations-darwin-arm64
chmod +x laravel-missing-translations-darwin-arm64
sudo mv laravel-missing-translations-darwin-arm64 /usr/local/bin/laravel-missing-translations

# macOS Intel
curl -LO https://github.com/OthmanHaba/laravel-missing-translations/releases/latest/download/laravel-missing-translations-darwin-amd64
chmod +x laravel-missing-translations-darwin-amd64
sudo mv laravel-missing-translations-darwin-amd64 /usr/local/bin/laravel-missing-translations

# Linux x64
curl -LO https://github.com/OthmanHaba/laravel-missing-translations/releases/latest/download/laravel-missing-translations-linux-amd64
chmod +x laravel-missing-translations-linux-amd64
sudo mv laravel-missing-translations-linux-amd64 /usr/local/bin/laravel-missing-translations

Or using tar.gz:

curl -LO https://github.com/OthmanHaba/laravel-missing-translations/releases/latest/download/laravel-missing-translations-darwin-arm64.tar.gz
tar -xzf laravel-missing-translations-darwin-arm64.tar.gz
chmod +x laravel-missing-translations-darwin-arm64
sudo mv laravel-missing-translations-darwin-arm64 /usr/local/bin/laravel-missing-translations

Windows

  1. Download the .exe file
  2. Add to your PATH or run directly from the download location

Build from Source

Requires Go 1.18+:

git clone https://github.com/OthmanHaba/laravel-missing-translations.git
cd laravel-missing-translations
make build

Binaries will be in the dist/ directory.

Usage

# Scan current directory with default locale (en)
laravel-missing-translations

# Specify Laravel project path
laravel-missing-translations -path /path/to/laravel/project

# Check a different locale
laravel-missing-translations -locale fr

# Exclude additional directories
laravel-missing-translations -exclude tests -exclude database

# Verbose output (shows loaded translation keys)
laravel-missing-translations -v

# Combine options
laravel-missing-translations -path ./my-app -locale es -exclude tests -v

Options

Flag Default Description
-path . Path to your Laravel project
-locale en Locale to check against (e.g., en, fr, es)
-exclude - Additional directories to exclude (can be used multiple times)
-v false Verbose output - shows all loaded translation keys

Default Excluded Directories

The following directories are excluded by default:

  • vendor
  • node_modules
  • lang
  • .git
  • storage
  • bootstrap/cache

Example Output

Loading translations from: lang/en
Loaded 150 translation keys

Scanning Laravel files...

Missing translation keys (3):

app/Http/Controllers/UserController.php:45 -> users.profile.title
resources/views/dashboard.blade.php:12 -> dashboard.welcome_message
resources/views/settings.blade.php:8 -> settings.notifications.email

Exit Codes

  • 0 - No missing translations found
  • 1 - Missing translations detected

This makes it easy to integrate into CI/CD pipelines:

# GitHub Actions example
- name: Check translations
  run: ./laravel-missing-translations -path ./

How It Works

  1. Loads translations from lang/{locale}/*.php files
  2. Parses PHP arrays including nested structures to build a complete key map
  3. Scans source files for translation calls: __('key'), trans('key'), @lang('key')
  4. Reports missing keys with file path and line number

License

MIT

About

A simple script that identify all missing translations in your Laravel Project

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors