I have written a custom translation function for Laravel, which first checks a configuration variable to see whether to use Laravel's default __() function or my custom trans() function.
Here's my function:
function t($key, $replace = [], $locale = null)
{
    $source = Config::get('translate.source');
    if ($source == 'database') {
        return trans($key, $replace, $locale);
    } else {
        return __($key, $replace, $locale);
    }
}
However, for speed purposes, I don't want the if condition to run reach time I call the t() function, but only on the first call.
Any ideas?
via Chebli Mohamed
 
Aucun commentaire:
Enregistrer un commentaire