nativecodein/laravel-translation-scanner
Laravel Translation Scanner is a zero-config Laravel package that scans your entire project — PHP, Blade, and Inertia React (JS / TS / JSX / TSX) files — and automatically appends every missing translation string to resources/lang/en.json.
Stop manually copy-pasting strings into your language files. Run one Artisan command and ship i18n-ready Laravel apps in seconds.
Works seamlessly with Laravel + Inertia.js + React, Blade, and pure PHP controllers. Supports Laravel 10, 11, 12, and 13.
__(), trans(), and t() call across your codebase.js, .ts, .jsx, and .tsx files for t("..."), t(\...`), and t(variable)` usageconst title = "Settings"; t(title) and adds Settingsen.json for clean diffsvendor/, node_modules/, bootstrap/, storage/, tests/, and other noiseInstall via Composer:
composer require nativecodein/laravel-translation-scanner
The service provider is auto-discovered. No further setup required.
Run the scanner from your Laravel project root:
php artisan translations:scan
The command will:
resources/lang/en.json (or create it if missing).en.json back to disk.Generate translated language JSON files automatically:
php artisan translations:translate ta
Example generated file:
resources/lang/ta.json
Translate multiple languages in one command:
php artisan translations:translate ta ar ro
Generated:
resources/lang/ta.json
resources/lang/ar.json
resources/lang/ro.json
The package automatically falls back between:
Google Translate
LibreTranslate
Lingva Translate
If one provider fails, the next provider is used automatically.
Built-in API protection:
usleep(300000);
This helps reduce temporary API blocking from free translation services.
{{ __('Dashboard') }}
{{ __('Plugins') }}
return trans('Welcome Back');
t("Login");
t("Register");
t(`Dashboard`);
const title = "Settings";
t(title);
After running php artisan translations:scan, your resources/lang/en.json:
{
"Dashboard": "Dashboard",
"Login": "Login",
"Plugins": "Plugins",
"Register": "Register",
"Settings": "Settings",
"Welcome Back": "Welcome Back"
}
Console output:
Added: Dashboard
Added: Plugins
Added: Welcome Back
Added: Login
Added: Settings
Translation scan completed.
| Extension | Scans For |
|---|---|
.php |
__('...'), trans('...') |
.blade.php |
__('...'), trans('...') |
.js |
t('...'), t(\...`), t(variable)` |
.ts |
t('...'), t(\...`), t(variable)` |
.jsx |
t('...'), t(\...`), t(variable)` |
.tsx |
t('...'), t(\...`), t(variable)` |
The scanner automatically skips these directories:
bootstrap/
config/
database/
routes/
storage/
tests/
vendor/
node_modules/
| Laravel | Status |
|---|---|
| 10.x | Supported |
| 11.x | Supported |
| 12.x | Supported |
| 13.x | Supported |
composer update nativecodein/laravel-translation-scanner
Then re-run:
php artisan translations:scan
php artisan translations:translate ta ar ro
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
If you discover any security-related issues, please email oss@nativecode.in instead of using the public issue tracker.
The MIT License (MIT). Please see LICENSE for more information.
Copyright © NativeCode.
How can I help you explore Laravel packages today?