afe/translation-tool-bundle
Symfony bundle providing CLI tools to audit translation keys: detect duplicated translation codes and find unused keys by scanning Twig/HTML/PHP/JS sources and YAML translation files. Configurable include/exclude paths, locales, and file masks.
Strengths:
vendor, node_modules) reduce false positives and adapt to project-specific needs.Weaknesses:
.yml files, excluding JSON (common in Laravel) and other formats without extension.AppKernel-style bundle registration, but modern Laravel (v5.5+) uses autoloading. Requires either:
php artisan translation:check).dev-master branch may introduce instability; pin to a stable release if available.resources/lang/). The bundle’s YAML focus necessitates either:
readme maturity label suggest low adoption/activity. Risk of breaking changes or abandonment.trans() helper, JSON files).trans('key', [], 'namespace')).trans() calls in Blade files).Why YAML-Only?
False Positives/Negatives:
trans('key.'.$variable)) or pluralization?trans_choice())?Maintenance Overhead:
Alternatives:
laravel-translation-manager, custom scripts) that offer similar functionality with lower risk?// app/Console/Commands/CheckTranslations.php
namespace App\Console\Commands;
use Symfony\Component\Process\Process;
class CheckTranslations extends Command {
protected function handle() {
$process = new Process(['php', 'app/console', 'afe:translation:check:codes']);
$process->run();
$this->output->write($process->getOutput());
}
}
AppServiceProvider (Laravel v5.5+) via:
$this->app->register(new \Afe\TranslationToolBundle\AfeTranslationToolBundle());
translation_files_dir_path to point to resources/lang/ (or a YAML-converted copy).fr.yml).trans() in Blade files).# .github/workflows/translation-check.yml
jobs:
translation-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: composer require afe/translation-tool-bundle:dev-master
- run: php artisan translation:check # Custom command
excluded_directories) can isolate the bundle to specific paths.dev-master branch may break without notice.composer.json.# config.yml
afe_translation_tool:
log_file: "%kernel.logs_dir%/translation_tool.log"
How can I help you explore Laravel packages today?