Skip to content

Instantly share code, notes, and snippets.

@somoza
Created January 21, 2021 19:57
Show Gist options
  • Save somoza/8d8bff22da15428e64683dd6cccb62c7 to your computer and use it in GitHub Desktop.
Save somoza/8d8bff22da15428e64683dd6cccb62c7 to your computer and use it in GitHub Desktop.
Find unused translations on Laravel with Tinker By @linktoahref
php artisan tinker
$translations = require resource_path('lang/en/app.php');
$unused_keys = [];
foreach ($translations as $key => $value) {
// Here app is the name of the translation file
// that was required in first step.
// Replace app with the name of the translation file that is been required.
$out = exec('echo $(grep -rn "app.' . $key . '" . --exclude-dir=vendor)');
echo strlen($out) . " " . $key . "\n";
if (strlen($out) <= 0) {
$unused_keys[] = $key;
}
}
@RobinBastiaan
Copy link

How do you use these multi lines in Tinker?

@somoza
Copy link
Author

somoza commented Apr 16, 2022

Sorry @RobinBastiaan I was traveling. Just add one by one or paste everything together...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment