Extend translations to generate log entries for missing translations.
This commit is contained in:
31
app/Translator.php
Normal file
31
app/Translator.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Translation\Translator as BaseTranslator;
|
||||
class Translator extends BaseTranslator
|
||||
{
|
||||
/**
|
||||
* @param string $key
|
||||
* @param array $replace
|
||||
* @param null $locale
|
||||
* @param bool $fallback
|
||||
*
|
||||
* @return array|null|string|void
|
||||
*/
|
||||
public function get($key, array $replace = [], $locale = null, $fallback = true)
|
||||
{
|
||||
$translation = parent::get($key, $replace, $locale, $fallback);
|
||||
|
||||
if ($translation === $key) {
|
||||
Log::warning('Language item could not be found.', [
|
||||
'language' => $locale ?? config('app.locale'),
|
||||
'id' => $key,
|
||||
'url' => config('app.url')
|
||||
]);
|
||||
}
|
||||
|
||||
return $translation;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user