sentry-laravel icon indicating copy to clipboard operation
sentry-laravel copied to clipboard

Report missing translations

Open khalyomede opened this issue 6 months ago • 0 comments

Problem Statement

I just stumble upon a feature in the documentation of Laravel 10 that allows us to perform any action when the framework encounter a missing translation.

Solution Brainstorm

To be able to report a missing translation by opt-in for Sentry to catch it:

// app/Providers/AppServiceProvider.php

public function boot(): void
{
    Lang::handleMissingKeysUsing(function (string $key, array $replacements, string $locale) {
        Sentry::reportMissingTranslation($key, $replacements, $locale);
 
        return $key;
    });
}

khalyomede avatar Dec 25 '23 15:12 khalyomede