Created
January 21, 2021 19:57
-
-
Save somoza/8d8bff22da15428e64683dd6cccb62c7 to your computer and use it in GitHub Desktop.
Find unused translations on Laravel with Tinker By @linktoahref
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you use these multi lines in Tinker?