syntaxas/laravel-lang-checker
Composer 安装命令:
composer require syntaxas/laravel-lang-checker
包简介
Laravel package for checking language files and translations.
README 文档
README
Laravel Lang Checker is a package for checking language files and translations in Laravel applications. It helps ensure that your translations are complete and consistent across different languages.
Requirements
- PHP 8.2, 8.3, 8.4, or 8.5
- Laravel 11, 12, or 13
Installation
You can install the package via composer:
composer require syntaxas/laravel-lang-checker
Usage
php artisan laravel-language:check
What It Checks
The command scans all locale directories under your lang/ path and runs the following checks:
| Check | Outcome |
|---|---|
lang/ directory does not exist |
❌ Fails |
| No locale subdirectories found | ⚠️ Warning, passes |
| A translation file exists in some locales but not all | ❌ Fails |
| A translation key exists in some locales but not all | ❌ Fails |
| A key is an array in one locale but a scalar value in another | ❌ Fails |
| A translation file does not return an array | ❌ Fails |
| A translation value is an empty string | ⚠️ Warning, passes |
Checks work recursively — files in subdirectories (e.g. /lang/lt/admin/dashboard.php) are included.
When the command fails, it reports the total number of issues found:
[ERROR] Language files check failed with 3 issue(s).
When everything is consistent:
[OK] Language files are consistent across all locales.
Examples
Missing translation key
lang/en/messages.php
return [ 'welcome' => 'Welcome', 'goodbye' => 'Goodbye', // present in EN ];
lang/lt/messages.php
return [ 'welcome' => 'Sveiki', // 'goodbye' is missing ];
[ERROR] LT locale missing goodbye translation in messages.php
Missing file
lang/en/auth.php — exists
lang/lt/auth.php — missing
[ERROR] Missing file for locale LT: auth.php
Type mismatch
lang/en/messages.php
return [ 'nav' => [ 'home' => 'Home', 'about' => 'About', ], ];
lang/lt/messages.php
return [ 'nav' => 'Navigacija', // scalar instead of array ];
[ERROR] Type mismatch for key nav in messages.php (EN=array, LT=value)
Empty translation
lang/en/messages.php
return [ 'welcome' => '', // empty string ];
[WARNING] Empty translation in messages.php (EN): welcome
All correct
lang/en/messages.php
return [ 'welcome' => 'Welcome', 'goodbye' => 'Goodbye', ];
lang/lt/messages.php
return [ 'welcome' => 'Sveiki', 'goodbye' => 'Viso gero', ];
[OK] Language files are consistent across all locales.
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-05